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 Quote Link to comment 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']; ?> Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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) ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.