3v4l.org

run code in 300+ PHP versions simultaneously
<?php $longString = 'I like apple. You like oranges. We like fruit. I like meat, also.'; $maxLineLength = 18; $words = explode(' ', $longString); $currentLength = 0; $index = 0; foreach ($words 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) { $output[$index] .= $word . ' '; $currentLength += $wordLength; } else { $index += 1; $currentLength = $wordLength; $output[$index] = $word; } } var_export($output);

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.4.130.0090.00918.84
8.4.120.0050.00323.95
8.4.110.0110.00718.84
8.4.100.0130.00718.95
8.4.90.0090.00818.88
8.4.80.0110.01018.79
8.4.70.0090.00918.09
8.4.60.0080.01018.48
8.4.50.0120.01220.41
8.4.40.0120.01519.66
8.4.30.0140.00020.46
8.4.20.0160.00317.84
8.4.10.0070.01120.51
8.3.260.0120.00716.95
8.3.250.0040.00519.13
8.3.240.0110.00717.03
8.3.230.0070.01016.93
8.3.220.0110.00518.94
8.3.210.0090.00916.78
8.3.200.0030.00616.88
8.3.190.0130.00417.34
8.3.180.0050.00318.88
8.3.170.0040.01820.87
8.3.160.0170.00017.28
8.3.150.0000.00817.13
8.3.140.0120.00620.69
8.3.130.0090.00018.40
8.3.120.0100.01019.08
8.3.110.0090.00020.94
8.3.100.0000.00818.44
8.3.90.0070.00018.57
8.3.80.0040.00419.36
8.3.70.0090.00616.75
8.3.60.0120.00616.63
8.3.50.0050.01524.49
8.3.40.0120.00620.27
8.3.30.0000.01518.68
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0080.00026.16
8.2.290.0100.00820.61
8.2.280.0110.01018.37
8.2.270.0080.00418.98
8.2.260.0110.00818.84
8.2.250.0040.00416.89
8.2.240.0040.00417.27
8.2.230.0050.00522.58
8.2.220.0060.00324.06
8.2.210.0040.00426.77
8.2.200.0060.00316.63
8.2.190.0070.01116.88
8.2.180.0190.00325.92
8.2.170.0110.00418.96
8.2.160.0070.00722.96
8.2.150.0140.00025.66
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0000.00726.35
8.2.110.0030.00621.12
8.2.100.0060.00617.72
8.2.90.0090.00018.03
8.2.80.0030.00617.97
8.2.70.0000.00818.16
8.2.60.0040.00418.22
8.2.50.0030.00718.10
8.2.40.0000.00719.34
8.2.30.0040.00419.26
8.2.20.0040.00418.09
8.2.10.0000.00719.19
8.2.00.0000.00819.37
8.1.330.0050.00422.14
8.1.320.0090.00316.18
8.1.310.0030.01416.53
8.1.300.0110.00718.08
8.1.290.0100.00018.88
8.1.280.0000.01425.92
8.1.270.0030.00723.99
8.1.260.0030.00628.09
8.1.250.0050.00328.09
8.1.240.0030.00622.24
8.1.230.0000.01222.75
8.1.220.0050.00317.74
8.1.210.0000.00819.04
8.1.200.0030.00617.36
8.1.190.0080.00017.35
8.1.180.0040.00418.10
8.1.170.0050.00318.44
8.1.160.0000.00918.89
8.1.150.0000.00818.93
8.1.140.0070.00018.94
8.1.130.0070.00020.14
8.1.120.0000.00817.42
8.1.110.0000.00817.49
8.1.100.0020.00517.39
8.1.90.0000.00717.48
8.1.80.0040.00417.42
8.1.70.0070.00017.34
8.1.60.0050.00317.57
8.1.50.0050.00317.57
8.1.40.0110.00517.42
8.1.30.0040.00817.56
8.1.20.0060.00617.58
8.1.10.0140.00317.49
8.1.00.0120.00617.40
8.0.300.0040.00420.08
8.0.290.0050.00316.75
8.0.280.0070.00018.45
8.0.270.0030.00616.95
8.0.260.0040.00418.39
8.0.250.0000.00717.06
8.0.240.0070.00016.89
8.0.230.0040.00417.04
8.0.220.0070.00016.86
8.0.210.0030.00316.87
8.0.200.0030.00317.10
8.0.190.0090.00016.91
8.0.180.0040.00416.95
8.0.170.0130.00016.89
8.0.160.0110.00116.98
8.0.150.0080.00516.84
8.0.140.0070.00616.84
8.0.130.0060.00515.11
8.0.120.0100.00316.85
8.0.110.0050.00516.86
8.0.100.0050.00516.90
8.0.90.0120.00016.99
8.0.80.0070.01216.91
8.0.70.0100.00416.93
8.0.60.0060.00616.96
8.0.50.0040.00816.93
8.0.30.0050.01116.97
8.0.20.0110.00716.98
8.0.10.0080.00317.02
8.0.00.0080.00816.90
7.4.330.0050.00015.55
7.4.320.0040.00416.44
7.4.300.0000.00616.46
7.4.290.0000.00716.49
7.4.280.0050.00516.46
7.4.270.0080.00516.55
7.4.260.0110.00214.83
7.4.250.0090.00316.50
7.4.240.0090.00416.40
7.4.230.0090.00316.58
7.4.220.0090.00416.43
7.4.210.0120.00716.55
7.4.200.0120.00216.42
7.4.190.0160.00316.60
7.4.180.0110.00716.50
7.4.160.0090.00516.34
7.4.150.0070.00716.33
7.4.140.0160.00016.39
7.4.130.0130.00916.44
7.4.120.0100.00616.49
7.4.110.0100.00716.48
7.4.100.0090.00716.41
7.4.90.0120.00516.34
7.4.80.0090.00816.48
7.4.70.0080.00716.35
7.4.60.0120.00416.34
7.4.50.0150.00216.48
7.4.40.0080.00716.26
7.4.30.0080.00816.49
7.4.20.0100.00616.32
7.4.10.0120.00416.49
7.4.00.0110.00516.46
7.3.330.0070.00616.34
7.3.320.0080.00414.64
7.3.310.0080.00616.28
7.3.300.0120.00216.34
7.3.290.0110.00816.34
7.3.280.0130.00616.22
7.3.270.0120.00616.34
7.3.260.0150.00316.36
7.3.250.0160.00416.35
7.3.240.0160.00316.41
7.3.230.0100.00816.42
7.3.220.0130.01016.23
7.3.210.0150.00916.40
7.3.200.0130.00716.43
7.3.190.0140.00716.29
7.3.180.0090.01216.33
7.3.170.0100.01116.45
7.3.160.0130.00616.32
7.3.150.0130.00616.39
7.3.140.0080.01116.38
7.3.130.0160.00416.49
7.3.120.0110.01016.21
7.3.110.0100.01116.46
7.3.100.0160.00316.30
7.3.90.0130.00816.35
7.3.80.0100.01116.41
7.3.70.0110.00916.33
7.3.60.0150.00416.44
7.3.50.0120.00816.33
7.3.40.0130.00616.38
7.3.30.0100.01016.33
7.3.20.0120.01117.34
7.3.10.0170.00317.32
7.3.00.0140.01117.28
7.2.340.0160.00316.34
7.2.330.0210.00416.52
7.2.320.0130.01016.46
7.2.310.0100.01216.32
7.2.300.0130.01016.60
7.2.290.0160.00716.36
7.2.280.0140.00816.45
7.2.270.0210.00216.51
7.2.260.0090.01216.51
7.2.250.0170.00516.61
7.2.240.0100.01316.38
7.2.230.0150.00816.52
7.2.220.0140.01016.45
7.2.210.0170.00616.48
7.2.200.0130.00916.59
7.2.190.0140.00816.55
7.2.180.0160.00516.57
7.2.170.0170.00416.61
7.2.160.0120.00916.57
7.2.150.0150.00617.45
7.2.140.0160.00617.50
7.2.130.0160.00717.57
7.2.120.0170.00717.65
7.2.110.0200.00617.62
7.2.100.0150.00817.63
7.2.90.0160.00717.41
7.2.80.0140.00817.41
7.2.70.0120.01017.57
7.2.60.0090.01217.56
7.2.50.0160.00717.42
7.2.40.0190.00717.46
7.2.30.0200.00517.64
7.2.20.0150.00817.55
7.2.10.0200.00617.56
7.2.00.0160.00817.55

preferences:
128.58 ms | 403 KiB | 5 Q