I am working on Flight api. I am sending the request(From location,To location,From date..etc) and i am getting the response in the array format as below.
Array
You will need to loop inside your array, level by level, and peint all relevant data you need. You can use foreach function to achieve this, please check documentation.
Ok First let me show you how to do this using a simple example
$myArray = array();
$myArray[] = array('name'=>'Russell');
$myArray[] = array('name'=>'Sam')
foreach($myArray as $list)
{
print $list['name'];
}
you can see what this example shows is it will loop through each array and get the name.
Now lets do a sub array in an array
$myArray = array();
$myArray[] = array('name'=>'Russell', 'about_me'=>array('age'=>22));
$myArray[] = array('name'=>'Sam', 'about_me'=>array('age'=>32))
foreach($myArray as $list)
{
print $list['name'];
}
foreach($myArray as $list)
{
print $list['name'];
print $list['about_me']['age']; <-- this will print about the age of the person.
}
First print your array:
print_r($yourarrayname);
Then print:
print_r($yourarrayname['AvailRequest']);
Then print:
print_r($yourarrayname['AvailRequest']['Trip']);
Then you will understand what I mean.