redbrad0 Posted December 17, 2007 Share Posted December 17, 2007 I have a array that I need help reading and looping thru the variables. I can get most of the data out of the array except for the "attr" sections of the rate (supplierID, chainCode, propertyID). I am looping thru all the other Array items by using this code below. Can someone help me with the code to get the "attr" sections of the array? $data = {The Array}' foreach($data['AvailResponse']['Rate'] as $rateKey => $r) { $RateCode = $r['rateCode']; $RateCodeDescription = $r['rateDescription']; } ( [AvailResponse] => Array ( [hotelID] => 1663 [hotelName] => Renaissance Oklahoma City Convention Center Hotel [smLogo] => http://image.pegs.com/brands/br/graphics/sm_brlogo.jpg [Address] => Array ( [city] => Oklahoma City [state] => OK [country] => US [postalCode] => 73102 [address1] => 10 North Broadway ) [Rate] => Array ( [0 attr] => Array ( [supplierID] => 1 [chainCode] => BR [propertyID] => OKCBR ) [0] => Array ( [rateCode] => E00 [commission] => 10.0 [Room] => Array ( [nativeCurrency] => USD [nativeCurrencyName] => American Dollars [roomDescription] => Marriott Senior Disc, Deluxe Room, 1 King Or 2 Double Beds Must Be Minimum 62 Years Of Age Valid Id Required [roomCode] => XMI [rate] => 135.00 [expectedCommission] => .00 [totalRate] => .00 [rateChange] => false [rateFrequency] => Nightly ) [rateDescription] => Marriott Senior Disc, Deluxe Room, 1 King Or 2 Double Beds Must Be Minimum 62 Years Of Age Valid Id Required ) [1 attr] => Array ( [supplierID] => 1 [chainCode] => BR [propertyID] => OKCBR ) [1] => Array ( [rateCode] => D00 [commission] => 10.0 [Room] => Array ( [nativeCurrency] => USD [nativeCurrencyName] => American Dollars [roomDescription] => Aaa Auto Association Rate * Deluxe Room -1 King Or 2 Dbl Beds- * Must Show Id At Check In * Limit Of Two Rooms [roomCode] => QAA [rate] => 143.00 [expectedCommission] => .00 [totalRate] => .00 [rateChange] => false [rateFrequency] => Nightly ) [rateDescription] => Aaa Auto Association Rate * Deluxe Room -1 King Or 2 Dbl Beds- * Must Show Id At Check In * Limit Of Two Rooms ) ) ) ) Quote Link to comment Share on other sites More sharing options...
vbnullchar Posted December 17, 2007 Share Posted December 17, 2007 i got a long solution to that <?php $lv1 = array( 'lv2' => array( 'lv3' => array( 'lv4'=>array('uno'=>'one','dos'=>'two') ) ) ); foreach($lv1 as $val_lv2) { foreach($val_lv2 as $val_lv3) { foreach($val_lv3 as $val_lv4) { foreach($val_lv4 as $value) { echo $value; } } } } Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted December 17, 2007 Share Posted December 17, 2007 print_r($ARRAY_NAME, "<br>"); that shoudl to what you want - hwever im not to familiar with the print_r function so please check it out on the php.net site. gdlk 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.