3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array['route'] = 'LINESTRING(-25.3233034167988 -57.640113830566406,-25.3229348965009 -57.64023184776306,-25.322653656571582 -57.63954520225525,-25.323410093517822 -57.63928771018982,-25.3229058027454 -57.6378607749939,-25.322973688164012 -57.63678789138794,-25.323371301994506 -57.63360142707825,-25.322003892857673 -57.633676528930664,-25.31995759927745 -57.633376121520996,-25.319336915717006 -57.63331174850464,-25.317988857651912 -57.63302206993103,-25.317377862364236 -57.63294696807861,-25.317688209562228 -57.62954592704773)'; $str = $array['route']; // Get the string from the array $str = substr( $str, 11); // Get rid of "LINESTRING(" $str = substr( $str, 0, strlen( $str) -1); // Get rid of trailing ")" $objective = str_getcsv( $str); // Form the objective array. foreach( $objective as $k => $v) { list( $x, $y) = explode( ' ', $v); $objective[$k] = array(); $objective[$k]['x'] = $x; $objective[$k]['y'] = $y; } print_r( $objective);
Output for 5.3.0 - 7.1.0
Array ( [0] => Array ( [x] => -25.3233034167988 [y] => -57.640113830566406 ) [1] => Array ( [x] => -25.3229348965009 [y] => -57.64023184776306 ) [2] => Array ( [x] => -25.322653656571582 [y] => -57.63954520225525 ) [3] => Array ( [x] => -25.323410093517822 [y] => -57.63928771018982 ) [4] => Array ( [x] => -25.3229058027454 [y] => -57.6378607749939 ) [5] => Array ( [x] => -25.322973688164012 [y] => -57.63678789138794 ) [6] => Array ( [x] => -25.323371301994506 [y] => -57.63360142707825 ) [7] => Array ( [x] => -25.322003892857673 [y] => -57.633676528930664 ) [8] => Array ( [x] => -25.31995759927745 [y] => -57.633376121520996 ) [9] => Array ( [x] => -25.319336915717006 [y] => -57.63331174850464 ) [10] => Array ( [x] => -25.317988857651912 [y] => -57.63302206993103 ) [11] => Array ( [x] => -25.317377862364236 [y] => -57.63294696807861 ) [12] => Array ( [x] => -25.317688209562228 [y] => -57.62954592704773 ) )
Output for 5.0.0 - 5.2.17
Fatal error: Call to undefined function str_getcsv() in /in/9dKsf on line 8
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: str_getcsv() in /in/9dKsf on line 8
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: str_getcsv() in /in/9dKsf on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: str_getcsv() in /in/9dKsf on line 8