How can I access AirportCode
of Origin
from the code below.Please Explain with foreach looping.
"Search": {
"FlightDataList": {
"JourneyList": [
[
{
"FlightDetails": {
"Details": [
[
{
"Origin": {
"AirportCode": "DEL",
"CityName": "Delhi",
"AirportName": "Delhi",
"DateTime": "2020-10-25 11:40:00"
},
"Destination": {
"AirportCode": "BOM",
"CityName": "Mumbai",
"AirportName": "Mumbai",
"DateTime": "2020-10-25 14:00:00"
}
}
]
]
}
"Price": {
"Currency": "INR",
"TotalDisplayFare": 4480,
"PriceBreakup": {
"BasicFare": 3870,
"Tax": 610,
"AgentCommission": 0,
"AgentTdsOnCommision": 0
}
}
}
]
]
}
}
I have attached my code. This code repeatedly shows AirportCode but I need only once
<?php
$obj= json_decode($json);
foreach($obj->Search->FlightDataList as $fdl){
foreach($fdl as $l1){
foreach($l1 as $l2){
foreach($l2->FlightDetails->Details as $l3){
foreach($l3 as $l4){
foreach ($l4 as $l5) {
echo $l5->AirportCode ?? '';
?>