Forum Moderators: coopster

Message Too Old, No Replies

php, xml and indeces

         

Pico_Train

6:15 pm on May 29, 2008 (gmt 0)

10+ Year Member



Hi there,

I am getting an xml feed in arrays.

I am then going through the arrays in php to insert into my DB.

The problem I have is that the indeces in some of the arrays from the XML feed switch between upper case and lower case at random.

so one array is:

'ADDRESS' => Array
(
'street2' => '',
'country' => 'country name',
'street1' => '101 street',
'street3' => '',
'state' => 'state',
'zip' => '9707',
'city' => 'city',
)

and the next one comes out as:

'ADDRESS' => Array
(
'street2' => '',
'COUNTRY' => 'country name',
'street1' => '101 street',
'street3' => '',
'state' => 'state',
'zip' => '9707',
'CITY' => 'city',
)

so when I loop through $var['city'] or $var['country'] throw errors as they are in upper case in the second array.

Any ideas how I can sort that out?

Thanks!

eelixduppy

7:50 pm on May 29, 2008 (gmt 0)



I would just create new variables that are associated with each element of the array. So something like this:

[url=http://www.php.net/list]list[/url]($street2, $country, $street1, $street3, $state, $zip, $city) = $var;