3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ 'StackOverFlow is the best site ever', // 22 ----------------^ 'http://stackoverflow.com is the best site ever', // 22 ----------------^ 'Short string', // no ellipsis needed ^ 'pneumonoultramicroscopicsilicovolcanoconiosis', // breakpoint between ^ letters ]; function word_wrap_custom($string, $limit) { $oneWord = explode(' ', $string); if(count($oneWord) < 2 ) return $oneWord[0]; $string = substr($string, 0, $limit + 2); $endchar = substr($string, $limit, $limit + 1); $postendchar = substr($string, $limit + 1, $limit + 2); $arrAccetpEndChar = array(' ', '!', '?', ',', '.', ';', ':'); if(in_array($postendchar, $arrAccetpEndChar) || in_array($endchar, $arrAccetpEndChar)) { return $string; } else { return preg_replace('/[A-Za-z0-9]+$/', '', $string); } } foreach ($strings as $string) { var_export( word_wrap_custom($string, 22) ); echo "\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.5.10.0110.00619.95
8.5.00.0160.00923.14
8.4.160.0120.00923.93
8.4.150.0010.00114.05
8.4.140.0100.01117.91
8.4.130.0110.01118.13
8.4.120.0110.01024.05
8.4.110.0050.00418.88
8.4.100.0120.00417.97
8.4.90.0100.00920.71
8.4.80.0120.00718.82
8.4.70.0110.00518.68
8.4.60.0080.01219.18
8.4.50.0130.00820.72
8.4.40.0090.01019.65
8.4.30.0070.01020.39
8.4.20.0030.00618.09
8.4.10.0160.00322.14
8.3.280.0090.01118.65
8.3.270.0090.01016.63
8.3.260.0170.00416.79
8.3.250.0100.01019.14
8.3.240.0120.00716.54
8.3.230.0120.00716.69
8.3.220.0050.00318.82
8.3.210.0070.00216.67
8.3.200.0050.00416.66
8.3.190.0110.00917.15
8.3.180.0120.00718.32
8.3.170.0000.00717.00
8.3.160.0130.00716.50
8.3.150.0140.00418.68
8.3.140.0030.00517.27
8.3.130.0080.00018.63
8.3.120.0060.01219.12
8.3.110.0040.00420.94
8.3.100.0040.00424.06
8.3.90.0000.01026.77
8.3.80.0060.00318.43
8.3.70.0100.01016.88
8.3.60.0100.00618.28
8.3.50.0070.00720.43
8.3.40.0070.01121.95
8.3.30.0040.01218.92
8.3.20.0050.00324.18
8.3.10.0000.00824.66
8.3.00.0080.00026.16
8.2.290.0040.00418.85
8.2.280.0060.00318.51
8.2.270.0110.00716.95
8.2.260.0060.00316.74
8.2.250.0080.00017.09
8.2.240.0130.00618.86
8.2.230.0060.00322.58
8.2.220.0080.00037.54
8.2.210.0000.00726.77
8.2.200.0090.00016.88
8.2.190.0120.00617.00
8.2.180.0000.01825.92
8.2.170.0120.00919.16
8.2.160.0110.00322.96
8.2.150.0000.01425.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00026.16
8.2.110.0070.00322.20
8.2.100.0110.00617.73
8.2.90.0100.00018.00
8.2.80.0030.00618.05
8.2.70.0030.00617.63
8.2.60.0080.00017.88
8.2.50.0040.00418.04
8.2.40.0040.00419.95
8.2.30.0030.00518.02
8.2.20.0040.00420.53
8.2.10.0040.00418.14
8.2.00.0040.00419.38
8.1.330.0090.00916.23
8.1.320.0130.00718.17
8.1.310.0050.00516.96
8.1.300.0060.00320.34
8.1.290.0090.00030.84
8.1.280.0160.00325.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0030.00622.64
8.1.230.0120.00419.01
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0030.00617.35
8.1.180.0000.01018.10
8.1.170.0000.00817.65
8.1.160.0030.00518.79
8.1.150.0050.00318.72
8.1.140.0000.00917.59
8.1.130.0030.00318.91
8.1.120.0030.00517.53
8.1.110.0040.00417.58
8.1.100.0080.00017.58
8.1.90.0000.00817.59
8.1.80.0050.00517.62
8.1.70.0120.00417.63
8.1.60.0120.00417.62
8.1.50.0100.01017.65
8.1.40.0120.00817.66
8.1.30.0120.00817.76
8.1.20.0140.00717.68
8.1.10.0170.00417.72
8.1.00.0100.01417.51
8.0.300.0040.00419.89
8.0.290.0020.00516.75
8.0.280.0000.00818.34
8.0.270.0040.00416.96
8.0.260.0040.00418.45
8.0.250.0070.00017.14
8.0.240.0030.00516.96
8.0.230.0050.00316.99
8.0.220.0070.00016.96
8.0.210.0140.00217.02
8.0.200.0110.00417.09
8.0.190.0100.00517.03
8.0.180.0060.00917.02
8.0.170.0120.00316.92
8.0.160.0110.00416.93
8.0.150.0130.00316.89
8.0.140.0140.00016.98
8.0.130.0130.00316.96
8.0.120.0090.00816.90
8.0.110.0090.00617.06
8.0.100.0070.00716.97
8.0.90.0070.00816.92
8.0.80.0150.00016.99
8.0.70.0160.00016.96
8.0.60.0130.00316.83
8.0.50.0150.00017.01
8.0.30.0050.00916.95
8.0.20.0040.01217.09
8.0.10.0120.00417.08
7.4.330.0050.00015.55
7.4.320.0040.00416.82
7.4.300.0150.00316.62
7.4.290.0120.00416.67
7.4.280.0110.00416.61
7.4.270.0030.00716.73
7.4.260.0130.00016.71
7.4.250.0140.00016.77
7.4.240.0110.00716.77
7.4.230.0130.00316.74
7.4.220.0100.00616.70
7.4.210.0120.00316.79
7.4.200.0110.00316.70
7.4.190.0070.00716.73
7.4.180.0110.00416.64
7.4.160.0110.00416.68
7.4.150.0110.00416.64
7.4.140.0090.00616.61
7.4.130.0110.00416.63
7.4.120.0110.00416.62
7.4.110.0120.00316.70
7.4.100.0120.00416.86
7.4.90.0050.01016.57
7.4.80.0070.00716.69
7.4.70.0090.00516.85
7.4.60.0100.00416.71
7.4.50.0120.00216.48
7.4.40.0110.00416.53
7.4.30.0110.00416.70
7.4.20.0080.00816.62
7.4.10.0110.00316.56
7.4.00.0140.00016.68

preferences:
48.76 ms | 403 KiB | 5 Q