3v4l.org

run code in 300+ PHP versions simultaneously
<?php $points = Array ( Array ( 45.29077, 5.63361 ), Array ( 45.29083, 5.63384 ) ); echo 'points = '; print_r($points); $json_parcours = array("type"=>"FeatureCollection", "features"=>array()); $coord_bdd = array(); foreach($points as $value){ //echo gettype($value[1]).' : '; $round1 = substr($value[1],0,7); $round2 = sprintf('%f.5', $value[0]); $round1 = floatval($round1); $round2 = floatval($round2); array_push($coord_bdd,array($round1,$round2)); //echo $round1.', '.$round2.'<br />'; echo '<br/><br/>coord_bdd = '; print_r($coord_bdd); } array_push($json_parcours["features"],array("type"=>"Feature","geometry"=>array("type"=>"LineString","coordinates"=>$coord_bdd),"properties"=>array())); $jsonData = json_encode($json_parcours,JSON_UNESCAPED_UNICODE); // Convertir le tableau en JSON echo '<br/><br/>jsonData = '; print_r($jsonData);

preferences:
20.42 ms | 408 KiB | 5 Q