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)); if(strtolower(trim($placeArr[count($placeArr)-1])) == "km" or strtolower(trim($placeArr[count($placeArr)-1])) == "kms"){ return strtolower(trim($placeArr[count($placeArr)-2]))." ".strtolower(trim($placeArr[count($placeArr)-1])) } } } print_r(sepNameDist("Birla Mandir 30 Km"));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.0.20.0330.07320.34
7.0.10.0030.04720.07
7.0.00.0100.08720.22
5.6.170.0400.06320.58
5.6.160.0170.06720.45
5.6.150.0070.08018.18
5.6.140.0070.08718.19
5.6.130.0000.08018.21
5.6.120.0030.08020.99
5.6.110.0100.03720.99
5.6.100.0070.08320.99
5.6.90.0230.07321.15
5.6.80.0000.04020.43
5.5.310.0370.07720.19
5.5.300.0030.07317.95
5.5.290.0030.04318.04
5.5.280.0100.04020.98
5.5.270.0100.03320.85
5.5.260.0130.07720.88
5.5.250.0030.05720.52
5.5.240.0000.07320.29

preferences:
154.87 ms | 1394 KiB | 7 Q