Answer the question
In order to leave comments, you need to log in
How to get out of loop in json?
Greetings.
There is this simple array traversal:
foreach ($cities as $city) {
if ($city['country_code'] == "$iata")
foreach ($city as $key => $value) {
$lat = $city ['coordinates']['lat'];
$lng = $city['coordinates']['lon'];
}
}
How to convert the result of the work to json?
{"lat":value,"lng":value}, {"lat":value,"lng":value}, etc.
It is clear that in the end using json_encode, but how exactly to pass the values?
Thank you.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question