[Solved] How to use foreach function in the the case of arrays of arrays [duplicate]


Just one thing… In your echo statement you have $s wrapped in single quotes (‘), the variable will not be read unless it’s in double quotes (“). ie: [“$s”]. Or you can do [”.$s.”] or just remove the quotes all together [$s].

And now the fix…

foreach($array_data['AvailResponse']['OriginDestinationOptions']['OriginDestinationOption']['0']['onward']['FlightSegments']['FlightSegment'] as $array)
{
    echo $c=$array['FlightNumber'];
}

Not a very elegant solution, but it works.

A link to the code working: http://phpfiddle.org/main/code/k9s-3i1

2

solved How to use foreach function in the the case of arrays of arrays [duplicate]