3v4l.org

run code in 300+ PHP versions simultaneously
<?php $longString = 'I like apple. You like oranges. We like fruit. I like meat, also.'; $arrayWords = explode(' ', $longString); $maxLineLength = 18; $currentLength = 0; $index = 0; foreach ($arrayWords as $word) { // +1 because the word will receive back the space in the end that it loses in explode() $wordLength = strlen($word) + 1; if (($currentLength + $wordLength) <= $maxLineLength) { $arrayOutput[$index] .= $word . ' '; $currentLength += $wordLength; } else { $index += 1; $currentLength = $wordLength; $arrayOutput[$index] = $word; } }

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.0100.01018.68
8.3.50.0120.00318.29
8.3.40.0070.00718.97
8.3.30.0070.00718.94
8.3.20.0070.00020.33
8.3.10.0000.00821.81
8.3.00.0040.00419.98
8.2.180.0070.00718.66
8.2.170.0110.00422.96
8.2.160.0030.01022.13
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0000.00726.16
8.2.120.0090.00019.49
8.2.110.0070.00422.29
8.2.100.0000.01119.40
8.2.90.0050.00318.03
8.2.80.0000.00919.45
8.2.70.0050.00317.92
8.2.60.0000.00718.04
8.2.50.0000.00718.10
8.2.40.0030.00622.37
8.2.30.0040.00419.41
8.2.20.0070.00018.09
8.2.10.0110.00018.04
8.2.00.0000.00718.18
8.1.280.0040.01125.92
8.1.270.0080.00020.23
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0080.00023.96
8.1.230.0040.00820.90
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0060.00317.35
8.1.190.0030.00617.48
8.1.180.0090.00018.10
8.1.170.0040.00418.65
8.1.160.0040.00418.75
8.1.150.0030.00320.32
8.1.140.0030.00617.61
8.1.130.0000.00718.89
8.1.120.0070.00017.41
8.1.110.0040.00417.39
8.1.100.0040.00417.45
8.1.90.0040.00717.39
8.1.80.0050.00317.36
8.1.70.0030.00317.51
8.1.60.0040.00417.55
8.1.50.0040.00417.41
8.1.40.0040.00417.54
8.1.30.0000.00817.60
8.1.20.0090.00017.59
8.1.10.0040.00717.44
8.1.00.0040.00417.56
8.0.300.0000.00720.04
8.0.290.0000.00816.63
8.0.280.0000.00718.50
8.0.270.0080.00017.27
8.0.260.0000.00816.82
8.0.250.0070.00016.98
8.0.240.0000.01117.01
8.0.230.0000.00716.98
8.0.220.0000.00716.95
8.0.210.0030.00316.93
8.0.200.0000.00716.94
8.0.190.0070.00316.94
8.0.180.0040.00416.97
8.0.170.0040.00416.96
8.0.160.0050.00217.01
8.0.150.0050.00216.96
8.0.140.0000.00816.84
8.0.130.0030.00313.39
8.0.120.0030.00516.86
8.0.110.0000.00716.95
8.0.100.0000.00716.93
8.0.90.0040.00417.03
8.0.80.0080.00816.92
8.0.70.0060.00316.75
8.0.60.0000.00817.01
8.0.50.0080.00016.93
8.0.30.0110.01017.21
8.0.20.0120.00917.40
8.0.10.0070.00016.88
8.0.00.0110.00716.84
7.4.330.0000.00415.55
7.4.320.0030.00316.61
7.4.300.0060.00016.58
7.4.290.0050.00216.47
7.4.280.0080.00016.64
7.4.270.0030.00616.59
7.4.260.0000.00716.41
7.4.250.0070.00016.59
7.4.240.0030.00316.55
7.4.230.0030.00316.63
7.4.220.0080.00016.54
7.4.210.0110.00316.58
7.4.200.0040.00416.31
7.4.160.0090.00816.59
7.4.150.0070.01117.40
7.4.140.0110.00717.86
7.4.130.0030.01316.40
7.4.120.0130.00716.45
7.4.110.0140.00316.63
7.4.100.0060.01016.53
7.4.90.0070.01016.75
7.4.80.0110.00719.39
7.4.70.0100.00716.66
7.4.60.0060.01516.59
7.4.50.0030.01216.41
7.4.40.0110.00616.71
7.4.00.0140.00315.16
7.3.330.0020.00213.23
7.3.320.0060.00013.26
7.3.310.0040.00416.26
7.3.300.0040.00416.28
7.3.290.0080.00816.44
7.3.280.0100.01116.33
7.3.270.0090.00917.40
7.3.260.0090.01316.45
7.3.250.0130.00816.50
7.3.240.0100.01016.54
7.3.230.0140.00316.41
7.3.210.0160.00616.53
7.3.200.0170.00416.66
7.3.190.0070.01016.61
7.3.180.0060.00916.32
7.3.170.0080.00916.37
7.3.160.0070.01416.43
7.2.330.0120.00616.62
7.2.320.0110.01116.59
7.2.310.0080.00816.74
7.2.300.0070.01016.72
7.2.290.0040.01116.54
7.2.60.0060.00616.72
7.2.10.0390.01317.48
7.2.00.0460.00717.63
7.1.200.0090.00315.68
7.1.130.0310.00916.86
7.1.120.0110.02216.55
7.1.110.0320.01316.11
7.1.100.0410.00616.37
7.1.90.0330.01015.98
7.1.80.0360.01316.05
7.1.70.0450.01315.31
7.1.60.0740.01733.18
7.1.50.0210.01832.74
7.1.40.0500.01632.55
7.1.30.0680.00732.58
7.1.20.0700.01932.80
7.1.10.0080.00814.54
7.1.00.0370.01314.74

preferences:
31.61 ms | 400 KiB | 5 Q