3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP $str = " Monday Tuesday Wednesday Thursday Friday\nSaturday\tSunday"; function a($str) { return str_word_count($str,1,"!\"#$%&'()*+,./0123456789-:;<=>?@[\]^_`{|}~"); }; function c($str) { return preg_split("/\s+/",trim($str)); }; function d($string){ return array_filter(explode(' ', implode(' ', array_map('trim', explode("\n", $string))))); }; function e($str) { $str = trim($str); $words = array(); $len = strlen($str); $word = ''; for ($i = 0; $i < $len; $i++) { $char = $str[$i]; $ord = ord($char); // Is a character if ($ord > 32 && $ord < 127) { $word .= $char; // It's some sort of whitespace } else { if ($word) { $words[] = $word; } $word = ''; } } if ($word) { $words[] = $word; } return $words; }; function f($str,$return_hash = false) { $str = trim($str); // Word characters are any printable char $words = str_word_count($str,1,"!\"#$%&'()*+,./0123456789-:;<=>?@[\]^_`{|}~"); if ($return_hash) { $ret = array(); $num = sizeof($words); // Odd number of elements, can't build a hash if ($num % 2 == 1) { return array(); } else { // Loop over each word and build a key/value hash for ($i = 0; $i < $num; $i += 2) { $key = $words[$i]; $value = $words[$i + 1]; $ret[$key] = $value; } return $ret; } } else { return $words; } }; ////////////(////////////////////////////////////////////////////////////////// a($str); c($str); d($str); e($str); f($str);

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.3.60.0040.01818.43
8.3.50.0110.01122.05
8.3.40.0120.00318.96
8.3.30.0140.00719.17
8.3.20.0040.00420.29
8.3.10.0040.00423.65
8.3.00.0040.00419.04
8.2.180.0090.00616.63
8.2.170.0120.00622.96
8.2.160.0070.00721.89
8.2.150.0050.00324.18
8.2.140.0090.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00421.12
8.2.110.0000.01021.05
8.2.100.0060.00617.95
8.2.90.0040.00417.75
8.2.80.0000.00819.04
8.2.70.0030.00518.03
8.2.60.0060.00318.09
8.2.50.0030.00918.10
8.2.40.0050.00319.30
8.2.30.0040.00419.26
8.2.20.0050.00317.99
8.2.10.0000.00718.11
8.2.00.0000.00817.88
8.1.280.0080.00825.92
8.1.270.0090.00019.13
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0060.00322.75
8.1.230.0070.00417.95
8.1.220.0040.00417.91
8.1.210.0040.00418.77
8.1.200.0000.00917.61
8.1.190.0030.00617.50
8.1.180.0040.00418.10
8.1.170.0040.00418.75
8.1.160.0090.00019.05
8.1.150.0040.00418.95
8.1.140.0000.00717.69
8.1.130.0050.00517.84
8.1.120.0040.00417.54
8.1.110.0000.00717.48
8.1.100.0050.00217.69
8.1.90.0000.00717.66
8.1.80.0000.00717.54
8.1.70.0000.00717.63
8.1.60.0000.00917.76
8.1.50.0040.00417.75
8.1.40.0050.00317.58
8.1.30.0000.00817.91
8.1.20.0040.00417.87
8.1.10.0030.00617.70
8.1.00.0040.00417.71
8.0.300.0080.00018.77
8.0.290.0040.00417.00
8.0.280.0050.00318.38
8.0.270.0000.00717.23
8.0.260.0040.00417.27
8.0.250.0000.00717.02
8.0.240.0000.00717.03
8.0.230.0000.00717.13
8.0.220.0040.00417.07
8.0.210.0030.00317.05
8.0.200.0040.00416.98
8.0.190.0040.00417.15
8.0.180.0040.00417.12
8.0.170.0080.00017.10
8.0.160.0040.00417.07
8.0.150.0070.00017.05
8.0.140.0080.00016.95
8.0.130.0000.00513.49
8.0.120.0040.00717.07
8.0.110.0050.00217.11
8.0.100.0030.00617.09
8.0.90.0060.00317.13
8.0.80.0120.00917.02
8.0.70.0000.00717.03
8.0.60.0050.00317.14
8.0.50.0070.00017.15
8.0.30.0100.01417.29
8.0.20.0110.01217.40
8.0.10.0080.00017.16
8.0.00.0110.01117.00
7.4.330.0070.00015.03
7.4.320.0000.00616.67
7.4.300.0000.00816.86
7.4.290.0070.00016.78
7.4.280.0040.00416.90
7.4.270.0030.00316.91
7.4.260.0000.00816.88
7.4.250.0040.00416.85
7.4.240.0020.00516.83
7.4.230.0000.00716.52
7.4.220.0030.01616.84
7.4.210.0090.00616.79
7.4.200.0000.00716.84
7.4.160.0120.00916.90
7.4.150.0120.00617.40
7.4.140.0080.01017.86
7.4.130.0050.01316.77
7.4.120.0080.00916.72
7.4.110.0150.00316.66
7.4.100.0090.01416.89
7.4.90.0000.01716.77
7.4.80.0220.00019.39
7.4.70.0150.01216.71
7.4.60.0110.00716.62
7.4.50.0030.00616.56
7.4.40.0060.01016.61
7.4.30.0030.01316.77
7.4.00.0110.00715.35
7.3.330.0030.00313.41
7.3.320.0000.00513.39
7.3.310.0000.00716.67
7.3.300.0030.00316.49
7.3.290.0050.00916.58
7.3.280.0080.01216.54
7.3.270.0120.00617.40
7.3.260.0090.00916.81
7.3.250.0080.01316.65
7.3.240.0120.00916.67
7.3.230.0100.00616.70
7.3.210.0140.00316.79
7.3.200.0100.00719.39
7.3.190.0190.00416.88
7.3.180.0100.00716.74
7.3.170.0070.01016.79
7.3.160.0090.00616.56
7.3.10.0030.00816.81
7.3.00.0030.00916.86
7.2.330.0070.01116.95
7.2.320.0160.00716.85
7.2.310.0070.01016.83
7.2.300.0100.00716.94
7.2.290.0130.01016.87
7.2.130.0030.01016.98
7.2.120.0070.00717.30
7.2.110.0040.00817.01
7.2.100.0060.00316.91
7.2.90.0040.01117.02
7.2.80.0000.01216.95
7.2.70.0000.01217.24
7.2.60.0080.00717.03
7.2.50.0030.00617.01
7.2.40.0120.00317.16
7.2.30.0000.01217.29
7.2.20.0040.00717.15
7.2.10.0090.00617.21
7.2.00.0050.01018.58
7.1.250.0000.00915.86
7.1.200.0030.01015.82
7.1.100.0000.01018.34
7.1.70.0070.00316.98
7.1.60.0100.00317.39
7.1.50.0260.01034.93
7.1.00.0130.08722.41
7.0.200.0000.01617.03
7.0.140.0030.06322.11
7.0.100.0300.08319.95
7.0.90.0030.07719.91
7.0.80.0130.04719.92
7.0.70.0130.04319.96
7.0.60.0230.05319.95
7.0.50.0070.06020.41
7.0.40.0030.06020.18
7.0.30.0000.05320.13
7.0.20.0100.04720.19
7.0.10.0100.06320.10
7.0.00.0100.05020.09
5.6.280.0030.07321.05
5.6.250.0070.04320.54
5.6.240.0030.08320.55
5.6.230.0100.06020.73
5.6.220.0000.08020.62
5.6.210.0070.04720.76
5.6.200.0100.08020.98
5.6.190.0000.05321.13
5.6.180.0130.04721.05
5.6.170.0070.08021.11
5.6.160.0130.03721.06
5.6.150.0130.04720.96
5.6.140.0100.08021.03
5.6.130.0130.05020.96
5.6.120.0030.06021.01
5.6.110.0130.06020.95
5.6.100.0170.05320.93
5.6.90.0130.06321.07
5.6.80.0100.04020.34
5.6.70.0130.03020.56
5.6.60.0030.05720.46
5.6.50.0100.04320.50
5.6.40.0070.04720.41
5.6.30.0070.05020.43
5.6.20.0100.04020.38
5.6.10.0070.06020.37
5.6.00.0070.06320.30
5.5.380.0070.07020.51
5.5.370.0100.04020.51
5.5.360.0030.04720.51
5.5.350.0030.06020.41
5.5.340.0170.04720.88
5.5.330.0200.06720.66
5.5.320.0070.08020.80
5.5.310.0070.06020.93
5.5.300.0030.07720.66
5.5.290.0130.07320.87
5.5.280.0030.08720.93
5.5.270.0100.08020.86
5.5.260.0170.08020.81
5.5.250.0070.06720.70
5.5.240.0030.04720.19
5.5.230.0200.04020.17
5.5.220.0100.08020.30
5.5.210.0100.06720.12
5.5.200.0200.04020.25
5.5.190.0070.05320.09
5.5.180.0070.06720.25
5.5.160.0030.05020.27
5.5.150.0070.07720.28
5.5.140.0000.08020.19
5.5.130.0070.06720.18
5.5.120.0070.07020.09
5.5.110.0030.07320.00
5.5.100.0070.05720.08
5.5.90.0070.04720.16
5.5.80.0070.06720.11
5.5.70.0070.07020.10
5.5.60.0130.05320.16
5.5.50.0130.06020.07
5.5.40.0070.06020.11
5.5.30.0070.04319.91
5.5.20.0100.07020.16
5.5.10.0030.04720.11
5.5.00.0000.08320.11
5.4.450.0070.08019.32
5.4.440.0070.04319.38
5.4.430.0100.06719.45
5.4.420.0070.05719.36
5.4.410.0070.04719.36
5.4.400.0030.08719.12
5.4.390.0030.04718.85
5.4.380.0170.05718.85
5.4.370.0170.06719.04
5.4.360.0070.07018.89
5.4.350.0070.04019.13
5.4.340.0030.06719.02
5.4.320.0030.07019.06
5.4.310.0130.05318.84
5.4.300.0100.04019.02
5.4.290.0070.06319.16
5.4.280.0100.05319.12
5.4.270.0030.05719.20
5.4.260.0100.05019.13
5.4.250.0030.04019.04
5.4.240.0070.04019.04
5.4.230.0130.06319.20
5.4.220.0070.06319.11
5.4.210.0070.04019.15
5.4.200.0030.04719.12
5.4.190.0100.05319.04
5.4.180.0070.04719.15
5.4.170.0200.06719.20
5.4.160.0030.06018.83
5.4.150.0130.03718.86
5.4.140.0030.07716.51
5.4.130.0070.06016.45
5.4.120.0070.05716.38
5.4.110.0030.05016.37
5.4.100.0070.07016.44
5.4.90.0030.07016.33
5.4.80.0070.03716.51
5.4.70.0100.06716.43
5.4.60.0030.05716.38
5.4.50.0070.04716.25
5.4.40.0130.04316.56
5.4.30.0000.07016.40
5.4.20.0030.06016.32
5.4.10.0070.04016.26
5.4.00.0030.07015.86
5.3.290.0070.04314.71
5.3.280.0100.06014.54
5.3.270.0130.06314.59
5.3.260.0030.06314.73
5.3.250.0100.07014.75
5.3.240.0130.06314.61
5.3.230.0130.04314.63
5.3.220.0030.08314.68
5.3.210.0000.06714.67
5.3.200.0070.07314.69
5.3.190.0230.06014.56
5.3.180.0100.05014.64
5.3.170.0030.05314.55
5.3.160.0030.06314.56
5.3.150.0030.08014.59
5.3.140.0030.05314.51
5.3.130.0100.06714.49
5.3.120.0070.04314.48
5.3.110.0100.06014.53
5.3.100.0070.06314.07
5.3.90.0100.03714.00
5.3.80.0030.07713.96
5.3.70.0170.06313.95
5.3.60.0130.05014.07
5.3.50.0200.05014.05
5.3.40.0070.05014.09
5.3.30.0070.05714.07
5.3.20.0070.06713.82
5.3.10.0070.06313.59
5.3.00.0070.05713.55
5.2.170.0070.06311.15
5.2.160.0100.03311.02
5.2.150.0070.03711.07
5.2.140.0030.05311.22
5.2.130.0070.03711.04
5.2.120.0070.05711.02
5.2.110.0100.05711.27
5.2.100.0000.04311.21
5.2.90.0070.02711.16
5.2.80.0070.05011.13
5.2.70.0000.06311.25
5.2.60.0100.04310.93
5.2.50.0030.05011.14
5.2.40.0070.05011.05
5.2.30.0030.03311.11
5.2.20.0100.05710.89
5.2.10.0030.05710.94
5.2.00.0000.06010.66
5.1.60.0030.02710.05
5.1.50.0170.03310.00
5.1.40.0070.02010.09
5.1.30.0000.05710.26
5.1.20.0000.05010.27
5.1.10.0000.0309.93
5.1.00.0100.0279.93
5.0.50.0000.0309.51
5.0.40.0070.0239.51
5.0.30.0000.0379.51
5.0.20.0030.0339.51
5.0.10.0070.0439.51
5.0.00.0070.0539.51
4.4.90.0030.0339.51
4.4.80.0070.0139.51
4.4.70.0100.0179.51
4.4.60.0000.0279.51
4.4.50.0030.0179.51
4.4.40.0000.0339.51
4.4.30.0000.0379.51
4.4.20.0000.0239.51
4.4.10.0000.0309.51
4.4.00.0030.0539.51
4.3.110.0000.0309.51
4.3.100.0000.0379.51
4.3.90.0030.0209.51
4.3.80.0070.0479.51
4.3.70.0030.0209.51
4.3.60.0030.0379.51
4.3.50.0030.0279.51
4.3.40.0000.0309.51
4.3.30.0030.0339.51
4.3.20.0000.0339.51
4.3.10.0000.0379.51
4.3.00.0130.0209.51

preferences:
34.57 ms | 401 KiB | 5 Q