stefanh Posted May 19, 2009 Share Posted May 19, 2009 Hi, This is my first message here, but I'm sure it won't be my last. I'm new to php so please bear with me. Heres my question. I'm running a script which converts a XML file to a extremely complicated nested array which I just can't seem to fathom, I would like to convert this to individual variables or a simpler array. Array ( [data] => Array ( [item] => Array ( [0] => Array ( [file] => 1.jpg [title] => Title Test 1 [description] => Desc Test 1 ) [1] => Array ( [file] => 2.jpg [title] => Title Test 2 [description] => Desc Test 2 ) ) ) ) What I would like is something like: file[0] = "1.jpg"; title[0] = "Title Test 1"; description[0] = "Desc Test 1"; file[1] = "2.jpg"; title[1] = "Title Test 2"; description[1] = "Desc Test 2"; Can someone help me understand my array? any help would be extremely appreciated. Thanks -Stefan Link to comment https://forums.phpfreaks.com/topic/158736-complicated-php-array-2-individual-variables/ Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 $file = array(); $title = array(); $description = array(); foreach($array['data']['item'] as $value){ //assuming your array is stored in $array $file[] = $value['file']; $title[] = $value['title']; $description[] = $value['description']; } Link to comment https://forums.phpfreaks.com/topic/158736-complicated-php-array-2-individual-variables/#findComment-837188 Share on other sites More sharing options...
stefanh Posted May 19, 2009 Author Share Posted May 19, 2009 Perfect! Thank You Link to comment https://forums.phpfreaks.com/topic/158736-complicated-php-array-2-individual-variables/#findComment-837224 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.