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(array($str)); c(array($str)); d(array($str)); e(array($str)); f(array($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.0070.01418.55
8.3.50.0100.01222.05
8.3.40.0100.00618.80
8.3.30.0070.00719.22
8.3.20.0070.00020.33
8.3.10.0080.00023.48
8.3.00.0040.00419.19
8.2.180.0090.00616.63
8.2.170.0150.00322.96
8.2.160.0100.01022.08
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0050.00226.16
8.2.120.0090.00021.21
8.2.110.0070.00320.46
8.2.100.0080.00417.91
8.2.90.0040.00417.84
8.2.80.0000.01017.97
8.2.70.0080.00017.79
8.2.60.0040.00418.03
8.2.50.0000.00818.10
8.2.40.0050.00319.36
8.2.30.0070.00019.37
8.2.20.0070.00017.79
8.2.10.0040.00418.19
8.2.00.0000.00717.86
8.1.280.0190.00625.92
8.1.270.0040.00419.08
8.1.260.0120.00326.35
8.1.250.0080.00028.09
8.1.240.0120.00317.48
8.1.230.0060.00621.01
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0030.00617.38
8.1.190.0050.00317.48
8.1.180.0030.00618.10
8.1.170.0000.00918.62
8.1.160.0070.00319.06
8.1.150.0000.00819.05
8.1.140.0000.00917.50
8.1.130.0000.00817.87
8.1.120.0000.00717.56
8.1.110.0040.00417.40
8.1.100.0080.00017.51
8.1.90.0000.00817.43
8.1.80.0000.00717.38
8.1.70.0040.00417.39
8.1.60.0030.00517.55
8.1.50.0000.00817.66
8.1.40.0000.00817.57
8.1.30.0030.00617.72
8.1.20.0030.00517.55
8.1.10.0040.00417.55
8.1.00.0080.00017.57
8.0.300.0040.00819.92
8.0.290.0030.00616.75
8.0.280.0030.00518.51
8.0.270.0000.00717.34
8.0.260.0030.00317.23
8.0.250.0000.00717.09
8.0.240.0000.00716.95
8.0.230.0040.00417.04
8.0.220.0000.00717.05
8.0.210.0030.00317.04
8.0.200.0090.00017.04
8.0.190.0080.00017.04
8.0.180.0030.00517.06
8.0.170.0020.00517.03
8.0.160.0080.00016.96
8.0.150.0040.00416.87
8.0.140.0040.00416.98
8.0.130.0030.00313.41
8.0.120.0040.00416.91
8.0.110.0070.00016.84
8.0.100.0000.00816.92
8.0.90.0040.00416.97
8.0.80.0110.00416.99
8.0.70.0050.00216.89
8.0.60.0040.00416.86
8.0.50.0000.00716.91
8.0.30.0040.01617.36
8.0.20.0080.01117.40
8.0.10.0080.00017.09
8.0.00.0110.00816.76
7.4.330.0030.00315.03
7.4.320.0030.00316.68
7.4.300.0000.00816.88
7.4.290.0040.00416.96
7.4.280.0000.00716.80
7.4.270.0030.00316.87
7.4.260.0000.00716.78
7.4.250.0040.00416.64
7.4.240.0070.00016.76
7.4.230.0030.00316.98
7.4.220.0120.00916.73
7.4.210.0150.00016.65
7.4.200.0000.00716.67
7.4.160.0090.00616.50
7.4.150.0160.00317.40
7.4.140.0100.00817.86
7.4.130.0110.00816.80
7.4.120.0110.00616.80
7.4.110.0070.01616.92
7.4.100.0090.00916.78
7.4.90.0170.00016.92
7.4.80.0120.01219.39
7.4.70.0280.03116.85
7.4.60.0130.00616.84
7.4.50.0000.00416.73
7.4.40.0030.01416.67
7.4.30.0140.00416.84
7.4.10.0060.00915.00
7.4.00.0100.00715.29
7.3.330.0030.00313.39
7.3.320.0050.00013.65
7.3.310.0040.00416.49
7.3.300.0050.00216.48
7.3.290.0050.00916.64
7.3.280.0100.00916.60
7.3.270.0120.00617.40
7.3.260.0130.00416.89
7.3.250.0080.01316.58
7.3.240.0080.01216.59
7.3.230.0090.00616.54
7.3.210.0070.01116.72
7.3.200.0070.01119.39
7.3.190.0100.00716.93
7.3.180.0100.00716.49
7.3.170.0130.01016.68
7.3.160.0030.01916.53
7.3.130.0070.01115.06
7.3.120.0200.00015.00
7.3.110.0080.00815.05
7.3.100.0120.00315.09
7.3.90.0120.00415.30
7.3.80.0110.00414.78
7.3.70.0030.00614.78
7.3.60.0030.00615.15
7.3.50.0000.01515.12
7.3.40.0070.00715.18
7.3.30.0040.01114.64
7.3.20.0090.00916.77
7.3.10.0030.01016.95
7.3.00.0090.00316.58
7.2.330.0120.01216.64
7.2.320.0150.00316.91
7.2.310.0030.01516.90
7.2.300.0090.00916.80
7.2.290.0040.01916.77
7.2.260.0090.00915.18
7.2.250.0040.01515.00
7.2.240.0100.00715.34
7.2.230.0090.00615.17
7.2.220.0050.00515.33
7.2.210.0070.00715.25
7.2.200.0000.00915.14
7.2.190.0140.00015.27
7.2.180.0000.01015.40
7.2.170.0060.00615.16
7.2.160.0060.00315.16
7.2.150.0040.00817.06
7.2.140.0070.01017.03
7.2.130.0070.00717.21
7.2.120.0070.00417.09
7.2.110.0030.00617.15
7.2.100.0090.00617.11
7.2.90.0060.01017.23
7.2.80.0060.00916.98
7.2.70.0060.00616.90
7.2.60.0080.00517.04
7.2.50.0030.00916.96
7.2.40.0030.01517.15
7.2.30.0030.01017.16
7.2.20.0070.00717.26
7.2.10.0080.00317.16
7.2.00.0040.01416.85
7.1.330.0140.00316.14
7.1.320.0070.00316.13
7.1.310.0120.00315.75
7.1.300.0000.01415.94
7.1.290.0000.00815.86
7.1.280.0000.01515.86
7.1.270.0090.00016.00
7.1.260.0070.00715.75
7.1.250.0030.01115.95
7.1.240.0090.00315.86
7.1.230.0100.00316.00
7.1.220.0030.01415.95
7.1.210.0090.00615.90
7.1.200.0050.00916.09
7.1.190.0040.00416.09
7.1.180.0060.00615.87
7.1.170.0030.00815.93
7.1.160.0040.01215.89
7.1.150.0030.01015.96
7.1.140.0000.01316.07
7.1.130.0060.00615.91
7.1.120.0030.01315.74
7.1.110.0060.00616.10
7.1.100.0100.00316.18
7.1.90.0070.01016.08
7.1.80.0070.00415.96
7.1.70.0070.00716.50
7.1.60.0030.01117.51
7.1.50.0110.00825.45
7.1.40.0090.00915.73
7.1.30.0030.01315.70
7.1.20.0030.01016.02
7.1.10.0060.00616.05
7.1.00.0070.05219.16
7.0.330.0040.01115.46
7.0.320.0040.01115.57
7.0.310.0060.00915.41
7.0.300.0060.00315.73
7.0.290.0100.00715.62
7.0.280.0040.00415.45
7.0.270.0040.01115.32
7.0.260.0000.00915.40
7.0.250.0000.01415.69
7.0.240.0000.01215.43
7.0.230.0060.01015.69
7.0.220.0040.01515.71
7.0.210.0060.00315.44
7.0.200.0140.00615.13
7.0.190.0030.01015.48
7.0.180.0030.01415.58
7.0.170.0030.01315.78
7.0.160.0070.01015.41
7.0.150.0060.00915.67
7.0.140.0020.02718.87
7.0.130.0030.01315.27
7.0.120.0100.01015.72
7.0.110.0040.00715.65
7.0.100.0000.01315.40
7.0.90.0040.01115.59
7.0.80.0100.00715.69
7.0.70.0030.00615.69
7.0.60.0190.03717.74
7.0.50.0030.04416.78
7.0.40.0080.04617.02
7.0.30.0120.03916.91
7.0.20.0220.04016.88
7.0.10.0080.04616.96
7.0.00.0090.04416.94
5.6.400.0030.01314.43
5.6.390.0000.00914.35
5.6.380.0060.00314.63
5.6.370.0080.00614.38
5.6.360.0090.00614.59
5.6.350.0060.00914.24
5.6.340.0100.00614.07
5.6.330.0030.01014.32
5.6.320.0030.01014.25
5.6.310.0040.00414.64
5.6.300.0000.01414.22
5.6.290.0070.00714.33
5.6.280.0050.04217.75
5.6.270.0070.01314.04
5.6.260.0040.00914.54
5.6.250.0080.00414.43
5.6.240.0070.00714.42
5.6.230.0030.01014.66
5.6.220.0030.00714.13
5.6.210.0030.03517.69
5.6.200.0080.01816.34
5.6.190.0100.02717.46
5.6.180.0120.02717.46
5.6.170.0120.02617.46
5.6.160.0070.03917.30
5.6.150.0070.02516.35
5.6.140.0050.04516.33
5.6.130.0070.03016.27
5.6.120.0020.02917.65
5.6.110.0060.04517.72
5.6.100.0050.04417.56
5.6.90.0070.04917.87
5.6.80.0050.03717.28
5.6.70.0120.00314.52
5.6.60.0060.01014.19
5.6.50.0060.00914.03
5.6.40.0070.01014.10
5.6.30.0040.00814.40
5.6.20.0030.01314.53
5.6.10.0110.00714.10
5.6.00.0040.00714.20
5.5.380.0050.00513.89
5.5.370.0040.01214.22
5.5.360.0060.00614.33
5.5.350.0170.03817.38
5.5.340.0060.02416.14
5.5.330.0080.04317.31
5.5.320.1820.02817.27
5.5.310.0150.03817.19
5.5.300.0110.04116.05
5.5.290.0050.04916.20
5.5.280.0120.04217.48
5.5.270.0120.03617.54
5.5.260.0140.04017.50
5.5.250.0050.04717.23
5.5.240.0140.03917.03
5.5.230.0090.00614.11
5.5.220.0040.01114.30
5.5.210.0140.00314.14
5.5.200.0100.00614.13
5.5.190.0030.01514.32
5.5.180.0090.00614.30
5.5.170.0030.00914.33
5.5.160.0100.00314.38
5.5.150.0000.01414.39
5.5.140.0110.00314.15
5.5.130.0080.00813.92
5.5.120.0070.00714.29
5.5.110.0070.01013.93
5.5.100.0030.01114.17
5.5.90.0070.00714.40
5.5.80.0000.01814.19
5.5.70.0040.01414.25
5.5.60.0000.01014.30
5.5.50.0000.01414.41
5.5.40.0060.00914.45
5.5.30.0030.01014.07
5.5.20.0040.01114.41
5.5.10.0070.00714.21
5.5.00.0040.00714.38
5.4.450.0050.04015.28
5.4.440.0350.03715.26
5.4.430.0140.02315.26
5.4.420.0480.03015.26
5.4.410.0500.02515.19
5.4.400.0430.02814.97
5.4.390.0180.03314.82
5.4.380.0190.03214.91
5.4.370.0180.03114.88
5.4.360.0100.03514.94
5.4.350.0200.03014.74
5.4.340.0120.03314.79
5.4.330.0000.00810.99
5.4.320.0130.03314.88
5.4.310.0180.03315.01
5.4.300.0120.03414.90
5.4.290.0200.03014.86
5.4.280.0240.02314.54
5.4.270.0160.03114.98
5.4.260.0150.03014.66
5.4.250.0230.03714.94
5.4.240.0180.03814.90
5.4.230.0170.03514.68
5.4.220.0180.03214.89
5.4.210.0170.03214.87
5.4.200.0180.02613.82
5.4.190.0180.03214.76
5.4.180.0170.03214.77
5.4.170.0200.02914.84
5.4.160.0150.03014.88
5.4.150.0180.04014.85
5.4.140.0290.02613.57
5.4.130.0220.03513.72
5.4.120.0260.03113.71
5.4.110.0180.03813.79
5.4.100.0190.02713.78
5.4.90.0150.03213.62
5.4.80.0150.03313.66
5.4.70.0200.03013.72
5.4.60.0170.02613.68
5.4.50.0190.02413.84
5.4.40.0210.02713.57
5.4.30.0150.02813.54
5.4.20.0150.03013.52
5.4.10.0200.02313.75
5.4.00.0150.02813.37
5.3.290.0300.05314.82
5.3.280.0230.05714.72
5.3.270.0300.05314.61
5.3.260.0230.06014.64
5.3.250.0500.04714.60
5.3.240.0430.05314.62
5.3.230.0300.05314.75
5.3.220.0300.05314.75
5.3.210.0230.06014.57
5.3.200.0270.05314.71
5.3.190.0300.05714.69
5.3.180.0230.06014.68
5.3.170.0230.05714.55
5.3.160.0300.05314.69
5.3.150.0370.04314.59
5.3.140.0330.04714.62
5.3.130.0300.05714.54
5.3.120.0230.07014.56
5.3.110.0400.05714.72
5.3.100.0430.04314.15
5.3.90.0430.04314.02
5.3.80.0230.06314.11
5.3.70.0370.04714.15
5.3.60.0300.05014.13
5.3.50.0270.05314.00
5.3.40.0270.05314.06
5.3.30.0270.06313.93
5.3.20.0330.04713.77
5.3.10.0300.04713.66
5.3.00.0300.05713.70
5.2.170.0370.03711.28
5.2.160.0270.04011.27
5.2.150.0270.04311.37
5.2.140.0170.05011.14
5.2.130.0300.03011.15
5.2.120.0170.04311.15
5.2.110.0200.04311.34
5.2.100.0270.04011.19
5.2.90.0300.04011.16
5.2.80.0170.04711.19
5.2.70.0270.05011.23
5.2.60.0230.04311.09
5.2.50.0370.04011.02
5.2.40.0170.05711.05
5.2.30.0200.04010.98
5.2.20.0200.04010.98
5.2.10.0130.04311.09
5.2.00.0170.04310.84
5.1.60.0130.03710.20
5.1.50.0170.03310.12
5.1.40.0130.04010.18
5.1.30.0130.04010.35
5.1.20.0200.03310.56
5.1.10.0200.04310.13
5.1.00.0170.03710.29
5.0.50.0130.0278.66
5.0.40.0100.0278.64
5.0.30.0100.0478.29
5.0.20.0130.0238.43
5.0.10.0130.0278.40
5.0.00.0130.0408.33
4.4.90.0070.0235.99
4.4.80.0070.0276.00
4.4.70.0100.0336.05
4.4.60.0100.0305.91
4.4.50.0170.0235.95
4.4.40.0100.0335.96
4.4.30.0170.0235.96
4.4.20.0070.0275.96
4.4.10.0070.0236.02
4.4.00.0030.0405.97
4.3.110.0130.0175.90
4.3.100.0170.0135.84
4.3.90.0100.0205.85
4.3.80.0030.0375.91
4.3.70.0100.0275.82
4.3.60.0070.0235.81
4.3.50.0070.0235.91
4.3.40.0100.0305.83
4.3.30.0070.0205.65
4.3.20.0030.0235.65
4.3.10.0000.0275.65
4.3.00.0070.0236.64

preferences:
73.6 ms | 401 KiB | 5 Q