3v4l.org

run code in 300+ PHP versions simultaneously
<?php header('Content-Type: text/html; charset=UTF-8'); function traffic($startlat, $startlon, $endlat, $endlon) { GLOBAL $traffic; $traffic=file_get_contents('https://www.waze.com/il-RoutingManager/routingRequest?from=x%3A'.$startlon.'+y%3A'.$startlat.'&to=x%3A'.$endlon.'+y%3A'.$endlat.'&at=0&returnJSON=true&timeout=60000&nPaths=1&clientVersion=4.0.0'); $traffic=json_decode($traffic,true); $tijd=0;$lengte=0; foreach($traffic['response']['results'] as $street) { $tijd = $tijd + $street['crossTime']; $lengte = $lengte + $street['length']; } $tijd = strftime("%M:%S",$tijd); $lengte = round($lengte / 1000,0); return array('tijd' => $tijd, 'lengte' => $lengte); } // $hw = traffic(50.892565,3.114135,50.877122,4.164326); // echo 'Home - Work = '.$hw['tijd'].' / '.$hw['lengte'].'km<br>'; // $wh = traffic(50.877122,4.164326,50.892565,3.114135); // echo 'Work - Home = '.$wh['tijd'].' / '.$wh['lengte'].'km<br>'; $hw = traffic(32.223122,34.993726,32.061679,34.793838); echo 'kokav - Work = '.$hw['tijd'].' / '.$hw['lengte'].'km<br>'; $hw = traffic(32.293122,34.993726,32.061679,34.793838); echo 'kokav2 - Work time MM:SS= '.$hw['tijd'].' / '.$hw['lengte'].'km<br>';

preferences:
39.65 ms | 402 KiB | 5 Q