3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sepNameDist($place){ $placeArr = explode("(",$place); if(count($placeArr)>1){ $array['name'] = ucwords(trim($placeArr[0])); $clean = strtolower(str_replace(" ","",trim(str_replace(")","",$placeArr[1])))); $matches = (preg_split('#(?<=\d)(?=[a-z])#i', $clean)); $num = $matches[0]; $txt = $matches[1]; if($num < 1 and (trim(strtolower($txt)) == "km" or (trim(strtolower($txt)) == "kms"))){ $num = $num*1000; $txt = "m"; $array['distance'] = $num." ".$txt; } else{ $array['distance'] = $num." ".$txt; } return $array; } else{ $placeArr = explode(" ",trim($place)); return $placeArr; } } print_r(sepNameDist("Birla Mandir 30 Km"));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Birla [1] => Mandir [2] => 30 [3] => Km )

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:
63.68 ms | 401 KiB | 8 Q