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);
Output for git.master_jit, git.master
points = Array ( [0] => Array ( [0] => 45.29077 [1] => 5.63361 ) [1] => Array ( [0] => 45.29083 [1] => 5.63384 ) ) <br/><br/>coord_bdd = Array ( [0] => Array ( [0] => 5.63361 [1] => 45.29077 ) ) <br/><br/>coord_bdd = Array ( [0] => Array ( [0] => 5.63361 [1] => 45.29077 ) [1] => Array ( [0] => 5.63384 [1] => 45.29083 ) ) <br/><br/>jsonData = {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[5.63361,45.29077],[5.63384,45.29083]]},"properties":[]}]}

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:
28.6 ms | 407 KiB | 5 Q