3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "data": [ { "sentenceArray": [ { "path": { "type": "walk", "nodes": [ { "lat": 39.952614, "lng": 32.854491 }, { "lat": 39.952083, "lng": 32.857761 } ] } }, { "path": { "type": "bus", "nodes": [ { "lat": 39.952418, "lng": 32.85727 }, { "lat": 39.952797, "lng": 32.856825 }, { "lat": 39.953102, "lng": 32.856438 } ] } }, { "path": { "type": "bus", "nodes": [ { "lat": 39.964951, "lng": 32.841305 }, { "lat": 39.964785, "lng": 32.841514 } ] } } ] }, { "sentenceArray": [ { "path": { "type": "walk", "nodes": [ { "lat": 39.952614, "lng": 32.854491 }, { "lat": 39.952083, "lng": 32.857761 } ] } }, { "path": { "type": "bus", "nodes": [ { "lat": 39.952418, "lng": 32.85727 }, { "lat": 39.952797, "lng": 32.856825 }, { "lat": 39.953102, "lng": 32.856438 } ] } }, { "path": { "type": "bus", "nodes": [ { "lat": 39.964951, "lng": 32.841305 }, { "lat": 39.964785, "lng": 32.841514 } ] } } ] } ] }'; $array = json_decode($json, true); foreach ($array['data'] as $datas) { foreach ($datas['sentenceArray'] as $subitem) { if ($subitem['path']['type'] == 'bus' && isset($subitem['path']['nodes'])) { $result[] = $subitem['path']['nodes']; } } } echo json_encode($result);
Output for git.master, git.master_jit, rfc.property-hooks
[[{"lat":39.952418,"lng":32.85727},{"lat":39.952797,"lng":32.856825},{"lat":39.953102,"lng":32.856438}],[{"lat":39.964951,"lng":32.841305},{"lat":39.964785,"lng":32.841514}],[{"lat":39.952418,"lng":32.85727},{"lat":39.952797,"lng":32.856825},{"lat":39.953102,"lng":32.856438}],[{"lat":39.964951,"lng":32.841305},{"lat":39.964785,"lng":32.841514}]]

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
137.15 ms | 406 KiB | 5 Q