3v4l.org

run code in 300+ PHP versions simultaneously
<?php function SilentGhost($z){ $z = strtolower($z); $z = preg_replace('/[^a-z0-9 -]+/', '', $z); $z = str_replace(' ', '-', $z); return trim($z, '-'); } function mario($z) { return strtolower(trim(preg_replace("/[^\w]+/", "-", $z), "-")); } function Rooneyl($string) { $new_string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string); $url = preg_replace('/\s/', '-', $new_string); $new_url = urlencode($url); return $new_url; } function AbhishekGoel($string) { $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one. } function HelloHack($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } function DenisMatafonov($str) { $withSpecCharacters = htmlspecialchars($str); $splitted_str = str_split($str); $result = ''; foreach ($splitted_str as $letter){ if (strpos($withSpecCharacters, $letter) !== false) { $result .= $letter; } } return $result; } function AdeelRazaAzeemi($str) { $str = str_replace(' ', '-', $str); $str = preg_replace('/[^\x20-\x7E]/', '', $str); return $str; } function mickmackusa($string) { return trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($string)), '-'); } $strings = [ 'This, is - - the URL!', 'Mork & Mindy', 'What the_underscore ?!?' ]; $funcs = ['SilentGhost', 'mario', 'Rooneyl', 'AbhishekGoel', 'HelloHack', 'DenisMatafonov', 'AdeelRazaAzeemi', 'mickmackusa']; foreach ($strings as $string) { echo "\n---\n" . var_export($string, true) . "\tinput\n"; foreach ($funcs as $func) { echo var_export($func($string), true) . "\t$func\n"; } }

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)
8.4.120.0130.00720.35
8.4.110.0090.01122.27
8.4.100.0130.00818.82
8.4.90.0140.00818.87
8.4.80.0120.00920.37
8.4.70.0030.00618.37
8.4.60.0130.00820.37
8.4.50.0120.00818.41
8.4.40.0130.00617.53
8.4.30.0030.01620.24
8.4.20.0100.01019.63
8.4.10.0130.00721.45
8.3.250.0080.01118.98
8.3.240.0070.00216.77
8.3.230.0130.00716.66
8.3.220.0100.00819.14
8.3.210.0100.00916.89
8.3.200.0040.00516.65
8.3.190.0050.00317.02
8.3.180.0080.01116.66
8.3.170.0050.00317.04
8.3.160.0130.00617.07
8.3.150.0070.01119.25
8.3.140.0040.00417.24
8.3.130.0080.00818.73
8.3.120.0060.01320.65
8.3.110.0030.00620.94
8.3.100.0030.00616.73
8.3.90.0000.00726.77
8.3.80.0030.00619.36
8.3.70.0070.01318.53
8.3.60.0130.00918.56
8.3.50.0100.00823.71
8.3.40.0110.00321.90
8.3.30.0120.00318.95
8.3.20.0030.00624.18
8.3.10.0080.00024.66
8.3.00.0040.00426.16
8.2.290.0050.00420.65
8.2.280.0120.00918.71
8.2.270.0070.01117.38
8.2.260.0060.00318.42
8.2.250.0040.00417.03
8.2.240.0030.00619.00
8.2.230.0060.00322.58
8.2.220.0030.00624.06
8.2.210.0040.01126.77
8.2.200.0030.00618.88
8.2.190.0090.00616.60
8.2.180.0030.01225.92
8.2.170.0060.00918.85
8.2.160.0100.01022.96
8.2.150.0090.00025.66
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00420.19
8.2.110.0100.00021.16
8.2.100.0070.00417.97
8.2.90.0030.00517.75
8.2.80.0060.00319.08
8.2.70.0050.00317.75
8.2.60.0040.00417.93
8.2.50.0030.00618.07
8.2.40.0040.00419.48
8.2.30.0070.00018.23
8.2.20.0000.00818.17
8.2.10.0070.00019.31
8.2.00.0030.00619.41
8.1.330.0110.00822.16
8.1.320.0070.01216.37
8.1.310.0040.00418.55
8.1.300.0030.00618.46
8.1.290.0000.00930.84
8.1.280.0090.00925.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00721.25
8.1.230.0120.00020.86
8.1.220.0000.00917.76
8.1.210.0000.00818.77
8.1.200.0060.00317.48
8.1.190.0030.00617.24
8.1.180.0030.00518.10
8.1.170.0080.00018.66
8.1.160.0040.00418.93
8.1.150.0000.00818.93
8.1.140.0000.00818.89
8.1.130.0070.00020.18
8.1.120.0050.00517.66
8.1.110.0050.00317.55
8.1.100.0070.00017.58
8.1.90.0080.00017.51
8.1.80.0000.00917.60
8.1.70.0070.00017.51
8.1.60.0000.01017.68
8.1.50.0000.00817.59
8.1.40.0030.00517.68
8.1.30.0080.00017.81
8.1.20.0000.00917.87
8.1.10.0030.00717.65
8.1.00.0060.00317.69
8.0.300.0040.00418.77
8.0.290.0030.00616.88
8.0.280.0000.00718.54
8.0.270.0050.00318.09
8.0.260.0030.00318.52
8.0.250.0000.00717.00
8.0.240.0030.00317.02
8.0.230.0000.00717.12
8.0.220.0000.00717.06
8.0.210.0000.00717.04
8.0.200.0000.00617.15
8.0.190.0080.00017.18
8.0.180.0000.00717.04
8.0.170.0000.00917.08
8.0.160.0070.00017.04
8.0.150.0000.00816.86
8.0.140.0040.00417.03
8.0.130.0030.00313.59
8.0.120.0030.00616.91
8.0.110.0040.00417.12
8.0.100.0040.00416.96
8.0.90.0080.00016.95
8.0.80.0050.01217.08
8.0.70.0030.00516.89
8.0.60.0040.00417.10
8.0.50.0000.00817.04
8.0.30.0090.00917.25
8.0.20.0130.00717.16
8.0.10.0030.00517.23
8.0.00.0130.00716.81
7.4.330.0000.00715.55
7.4.320.0040.00416.80
7.4.300.0000.00716.79
7.4.290.0000.00816.59
7.4.280.0020.00516.69
7.4.270.0000.00716.88
7.4.260.0030.00313.43
7.4.250.0040.00416.78
7.4.240.0040.00416.84
7.4.230.0040.00316.72
7.4.220.0000.00716.88
7.4.210.0070.00916.73
7.4.200.0030.00316.85
7.4.130.0100.01016.54
7.4.120.0110.00716.54
7.4.110.0160.00316.43
7.4.100.0130.00716.44
7.4.90.0070.01716.41
7.4.80.0160.00316.55
7.4.70.0130.00616.73
7.4.60.0140.01116.54
7.4.50.0180.00016.43
7.4.40.0140.01116.59
7.4.30.0090.01216.63
7.4.20.0100.01016.34
7.4.10.0100.00916.39
7.4.00.0070.01116.69
7.3.330.0040.00416.66
7.3.320.0030.00313.46
7.3.310.0030.00416.45
7.3.300.0060.00016.42
7.3.290.0060.00916.54
7.3.260.0070.01116.59
7.3.250.0130.00516.91
7.3.240.0120.00616.86
7.3.230.0170.00316.70
7.3.220.0060.01516.79
7.3.210.0130.00616.86
7.3.200.0060.01316.66
7.3.190.0030.01516.59
7.3.180.0160.00916.59
7.3.170.0090.01016.71
7.3.160.0160.01016.35
7.3.150.0150.00416.66
7.3.140.0060.01216.79
7.3.130.0140.00416.71
7.3.120.0140.00316.53
7.3.110.0110.00616.78
7.3.100.0040.01516.74
7.3.90.0180.00616.63
7.3.80.0050.01416.73
7.3.70.0090.00916.56
7.3.60.0110.00716.47
7.3.50.0140.00516.64
7.3.40.0170.00716.48
7.3.30.0080.01116.63
7.3.20.0080.01216.63
7.3.10.0110.00816.64
7.3.00.0090.00916.48

preferences:
29.5 ms | 403 KiB | 5 Q