MrRundog Posted June 27, 2008 Share Posted June 27, 2008 Hi Folks - Fro this multi array I need to extract the [Vehicle] array info or ineed the whole [vehicle] array itself - Would someone know the correct loop or extraction method please? Array ( [] => Array ( [release] => 8.1 [environment] => Production [lang] => en-US [xmlns] => [ApplicationArea] => Array ( [sender] => Array ( [LogicalId] => 0 [Component] => CarweBVRRWebService [Task] => strB2BGetVehicleByVRM ) [CreationDateTime] => 2008-06-25T13.52.52Z [bODId] => [Destination] => Array ( [DestinationNameCode] => 1 ) ) [DataArea] => Array ( [Error] => Array ( [Header] => Array ( [DocumentDateTime] => 2008-06-25T13.52.52Z ) ) [Vehicles] => Array ( [Vehicle] => Array ( [bodyStyle] => 4 DOOR SALOON [CO2] => 151 [DateFirstRegistered] => 2001-12-03 ) ) ) ) ) Cheers MR Link to comment https://forums.phpfreaks.com/topic/112177-extract-nested-array-from-main-array/ Share on other sites More sharing options...
thebadbad Posted June 27, 2008 Share Posted June 27, 2008 If we call the main array $array, then try: <?php $vehicle_array = $array[0]['DataArea']['Vehicles']['Vehicle']; ?> Link to comment https://forums.phpfreaks.com/topic/112177-extract-nested-array-from-main-array/#findComment-575860 Share on other sites More sharing options...
MrRundog Posted June 27, 2008 Author Share Posted June 27, 2008 Hi thanks for the reply - The actual array is called $data I tried the above but it isn't showing any result print_r($arrayName) Andy Link to comment https://forums.phpfreaks.com/topic/112177-extract-nested-array-from-main-array/#findComment-575864 Share on other sites More sharing options...
thebadbad Posted June 27, 2008 Share Posted June 27, 2008 Can you show me a var_dump of the main array? Link to comment https://forums.phpfreaks.com/topic/112177-extract-nested-array-from-main-array/#findComment-575871 Share on other sites More sharing options...
ScotDiddle Posted June 27, 2008 Share Posted June 27, 2008 MrRundog, It worked for me when I assigned the Second Level array a Key value a value of zero. Scot L. Diddle, Richmond VA <?php $data = Array ( 0 => Array ( 'release' => 8.1, 'environment' => Production, 'lang' => en-US, 'xmlns' => NULL, 'ApplicationArea' => Array ( 'Sender' => Array ( 'LogicalId' => 0, 'Component' => CarweBVRRWebService, 'Task' => strB2BGetVehicleByVRM, ), 'CreationDateTime' => '2008-06-25T13.52.52Z', 'BODId' => NULL, 'Destination' => Array ( 'DestinationNameCode' => 1, ) ), 'DataArea' => Array ( 'Error' => Array ( 'Header' => Array ( 'DocumentDateTime' => '2008-06-25T13.52.52Z' ) ), 'Vehicles' => Array ( 'Vehicle' => Array ( 'BodyStyle' => '4 DOOR SALOON', 'CO2' => 151, 'DateFirstRegistered' => '2001-12-03', ) ), ), ), ); $vehicle_array = $data[0]['DataArea']['Vehicles']['Vehicle']; print_r($vehicle_array) ?> Link to comment https://forums.phpfreaks.com/topic/112177-extract-nested-array-from-main-array/#findComment-575872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.