Jump to content

Reading a array


redbrad0

Recommended Posts

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
                        )

                )
        )

)

Link to comment
Share on other sites

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;
		}
	}
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.