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.0140.00718.43
8.3.50.0090.00918.05
8.3.40.0110.00318.80
8.3.30.0120.00318.94
8.3.20.0080.00020.25
8.3.10.0070.00021.89
8.3.00.0040.00419.26
8.2.180.0160.00318.41
8.2.170.0060.00922.96
8.2.160.0100.01020.52
8.2.150.0000.00724.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0080.00019.36
8.2.110.0090.00020.91
8.2.100.0040.00817.50
8.2.90.0060.00319.17
8.2.80.0000.00817.97
8.2.70.0040.00417.48
8.2.60.0030.00517.90
8.2.50.0040.00418.07
8.2.40.0060.00319.95
8.2.30.0040.00417.92
8.2.20.0050.00217.64
8.2.10.0030.00618.10
8.2.00.0030.00517.56
8.1.280.0110.00725.92
8.1.270.0060.00320.16
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00322.74
8.1.230.0090.00317.42
8.1.220.0030.00617.74
8.1.210.0000.00918.77
8.1.200.0030.00617.22
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0030.00520.17
8.1.160.0040.00421.92
8.1.150.0000.00718.73
8.1.140.0040.00417.43
8.1.130.0060.00317.88
8.1.120.0030.00317.42
8.1.110.0040.00417.43
8.1.100.0000.00717.39
8.1.90.0040.00417.41
8.1.80.0000.00717.43
8.1.70.0070.00017.45
8.1.60.0060.00317.62
8.1.50.0060.00317.61
8.1.40.0000.00717.39
8.1.30.0030.00517.77
8.1.20.0040.00417.68
8.1.10.0110.00017.45
8.1.00.0030.00617.41
8.0.300.0040.00418.77
8.0.290.0040.00416.63
8.0.280.0030.00318.41
8.0.270.0030.00317.22
8.0.260.0050.00317.22
8.0.250.0000.00616.92
8.0.240.0000.00716.82
8.0.230.0070.00016.86
8.0.220.0070.00016.72
8.0.210.0070.00016.82
8.0.200.0030.00716.96
8.0.190.0100.00016.93
8.0.180.0000.00716.94
8.0.170.0040.00416.79
8.0.160.0000.00716.89
8.0.150.0060.00316.88
8.0.140.0070.00016.72
8.0.130.0000.00713.25
8.0.120.0040.00416.73
8.0.110.0080.00016.86
8.0.100.0000.00816.84
8.0.90.0000.00716.75
8.0.80.0100.00616.88
8.0.70.0050.00216.98
8.0.60.0000.00716.82
8.0.50.0070.00016.64
8.0.30.0090.01016.95
8.0.20.0110.00817.40
8.0.10.0070.00016.96
8.0.00.0060.01116.68
7.4.330.0020.00215.03
7.4.320.0000.00616.38
7.4.300.0060.00016.64
7.4.290.0030.00316.55
7.4.280.0060.00316.55
7.4.270.0030.00316.64
7.4.260.0000.00816.60
7.4.250.0050.00316.50
7.4.240.0020.00516.58
7.4.230.0030.00316.65
7.4.220.0110.01116.45
7.4.210.0100.00516.62
7.4.200.0000.00716.43
7.4.160.0140.00616.56
7.4.150.0180.00017.40
7.4.140.0130.01417.86
7.4.130.0100.00816.42
7.4.120.0090.00916.40
7.4.110.0030.01616.63
7.4.100.0150.00616.57
7.4.90.0100.00716.49
7.4.80.0180.00719.39
7.4.70.0100.00716.63
7.4.60.0070.01016.62
7.4.50.0090.00016.63
7.4.40.0040.01416.57
7.4.30.0140.00316.50
7.4.00.0040.00814.91
7.3.330.0060.00013.11
7.3.320.0090.00313.21
7.3.310.0070.00016.17
7.3.300.0030.00316.24
7.3.290.0000.00716.33
7.3.280.0070.00816.29
7.3.270.0100.00617.40
7.3.260.0030.01316.33
7.3.250.0090.01116.43
7.3.240.0120.00616.32
7.3.230.0090.01216.39
7.3.210.0100.00616.24
7.3.200.0070.01019.39
7.3.190.0060.00916.37
7.3.180.0120.00316.23
7.3.170.0030.01316.39
7.3.160.0040.01216.21
7.2.330.0080.00816.62
7.2.320.0140.01016.45
7.2.310.0030.01316.67
7.2.300.0170.00016.44
7.2.290.0140.00416.65
7.2.00.0030.00919.34
7.1.100.0060.00917.89
7.1.70.0070.00717.21
7.1.60.0110.01419.50
7.1.50.0180.00716.95
7.1.00.0030.07722.45
7.0.200.0620.00914.74
7.0.140.0030.07721.95
7.0.60.0070.06020.05
7.0.50.0100.06317.96
7.0.40.0000.06020.18
7.0.30.0270.05020.06
7.0.20.0270.06020.09
7.0.10.0230.07020.16
7.0.00.0130.08320.22
5.6.280.0030.07021.13
5.6.210.0000.05020.63
5.6.200.0000.04318.28
5.6.190.0100.08320.41
5.6.180.0230.04320.37
5.6.170.0200.05320.57
5.6.160.0070.08020.57
5.6.150.0070.04018.29
5.6.140.0070.08318.15
5.6.130.0100.07718.14
5.6.120.0200.06321.03
5.6.110.0030.05721.00
5.6.100.0100.03720.98
5.6.90.0070.07321.11
5.6.80.0070.07020.42
5.6.70.0230.06720.54
5.5.350.0300.05720.39
5.5.340.0100.07717.93
5.5.330.0100.07720.40
5.5.320.0000.06320.20
5.5.310.0270.07320.19
5.5.300.0170.07017.93
5.5.290.0100.08017.95
5.5.280.0070.05020.79
5.5.270.0030.09020.63
5.5.260.0100.03720.88
5.5.250.0100.03720.63
5.5.240.0030.08720.30
5.4.450.0200.05019.20
5.4.440.1070.08019.48
5.4.430.1100.06319.63
5.4.420.0370.05719.55
5.4.410.0130.05719.06
5.4.400.0500.05318.75
5.4.390.0570.07018.52
5.4.380.0330.06718.84
5.4.370.0500.07018.70
5.4.360.1270.07018.57
5.4.350.0330.05718.84
5.4.340.0470.05018.63
5.4.320.0530.06018.73
5.4.310.0400.07318.80
5.4.300.1230.08318.83
5.4.290.0400.07018.59
5.4.280.0200.08018.80
5.4.270.0570.07718.72
5.4.260.0500.06318.58
5.4.250.0530.06318.78
5.4.240.0370.06718.72
5.4.230.0430.06318.60
5.4.220.0470.07318.70
5.4.210.0370.05718.77
5.4.200.0400.06316.59
5.4.190.0100.06018.77
5.4.180.1230.05718.69
5.4.170.0430.05318.71
5.4.160.1400.06018.61
5.4.150.0670.05718.71
5.4.140.0170.06016.27
5.4.130.0630.04716.20
5.4.120.0500.06016.45
5.4.110.0370.06016.27
5.4.100.0400.06716.37
5.4.90.0670.07016.27
5.4.80.0300.06316.35
5.4.70.0300.06016.27
5.4.60.0570.05316.18
5.4.50.0370.05716.25
5.4.40.0400.05016.42
5.4.30.0330.05716.15
5.4.20.0530.06716.14
5.4.10.0430.05716.41
5.4.00.0400.04715.78
5.3.290.0400.07014.90
5.3.280.0470.05714.61
5.3.270.0400.08014.62
5.3.260.0430.08014.78
5.3.250.0400.05714.73
5.3.240.1000.06014.65
5.3.230.0330.07314.80
5.3.220.0430.05014.62
5.3.210.0370.05314.71
5.3.200.1030.05714.76
5.3.190.0400.05314.58
5.3.180.1330.06314.62
5.3.170.0300.07014.56
5.3.160.0430.06714.63
5.3.150.0570.06314.79
5.3.140.1170.06014.79
5.3.130.0230.06014.76
5.3.120.0130.06014.79
5.3.110.0170.05714.66
5.3.100.0500.05014.10
5.3.90.0530.05014.07
5.3.80.0370.06314.08
5.3.70.0500.06314.13
5.3.60.1600.06314.01
5.3.50.0430.05714.01
5.3.40.1070.06713.96
5.3.30.0470.06714.03
5.3.20.0430.05013.70
5.3.10.0600.06013.71
5.3.00.0530.05313.72
5.2.170.0270.05311.22
5.2.160.0500.04311.21
5.2.150.0400.04711.26
5.2.140.0270.05011.28
5.2.130.0270.05011.14
5.2.120.0330.03311.14
5.2.110.0370.04311.33
5.2.100.0300.05011.22
5.2.90.0300.03711.11
5.2.80.0330.04311.16
5.2.70.0300.04711.13
5.2.60.0500.03711.07
5.2.50.0370.05011.04
5.2.40.0270.05011.22
5.2.30.0370.04710.98
5.2.20.0130.05711.18
5.2.10.0270.04010.90
5.2.00.0330.04710.79
5.1.60.0200.04010.20
5.1.50.0230.03710.05
5.1.40.0200.04010.03
5.1.30.0330.03310.48
5.1.20.0300.05310.55
5.1.10.0270.04310.12
5.1.00.0270.04710.29
5.0.50.0070.0408.76
5.0.40.0130.0308.47
5.0.30.0100.0478.34
5.0.20.0100.0278.36
5.0.10.0130.0308.39
5.0.00.0100.0478.39
4.4.90.0030.0276.02
4.4.80.0070.0305.96
4.4.70.0170.0235.95
4.4.60.0170.0305.89
4.4.50.0130.0305.94
4.4.40.0170.0476.00
4.4.30.0170.0235.90
4.4.20.0200.0276.00
4.4.10.0030.0275.99
4.4.00.0130.0406.04
4.3.110.0130.0275.90
4.3.100.0200.0175.85
4.3.90.0130.0205.85
4.3.80.0130.0405.84
4.3.70.0200.0275.83
4.3.60.0170.0235.86
4.3.50.0130.0175.83
4.3.40.0070.0435.80
4.3.30.0000.0304.63
4.3.20.0070.0234.61
4.3.10.0100.0234.54
4.3.00.0100.0236.66

preferences:
61.5 ms | 400 KiB | 5 Q