3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "I am a boy like desired and expected"; for ( $offset = 0, $length = strlen($string); $offset < $length; ++$offset ) { $offset += $string[$offset] === ' '; echo "word at offset $offset, call strpos()\n"; for ( $swaps = 0, $wordEnd = (strpos($string, ' ', $offset) ?: $length) - 1; $offset < $wordEnd; ++$swaps, ++$offset, --$wordEnd ) { [$string[$wordEnd], $string[$offset]] = [$string[$offset], $string[$wordEnd]]; echo "$offset : $wordEnd : $swaps : $string\n"; } $offset += $swaps; } echo $string;

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.130.0070.00018.47
8.3.120.0050.00318.89
8.3.110.0060.00320.94
8.3.100.0160.00324.06
8.3.90.0040.00426.77
8.3.80.0000.01118.42
8.3.70.0110.01416.58
8.3.60.0090.00916.63
8.3.50.0140.00720.14
8.3.40.0110.00419.96
8.3.30.0150.00018.48
8.3.20.0140.00024.18
8.3.10.0140.00024.66
8.3.00.0050.00326.16
8.2.250.0150.00416.50
8.2.240.0050.00519.23
8.2.230.0060.01022.58
8.2.220.0130.00637.54
8.2.210.0110.00426.77
8.2.200.0030.00716.50
8.2.190.0120.00618.09
8.2.180.0110.00625.92
8.2.170.0120.00318.91
8.2.160.0030.01022.96
8.2.150.0040.00425.66
8.2.140.0050.00224.66
8.2.130.0040.00426.16
8.2.120.0000.00819.48
8.2.110.0030.00622.25
8.2.100.0070.00417.84
8.2.90.0000.00817.91
8.2.80.0060.00319.28
8.2.70.0030.00917.63
8.2.60.0030.00617.93
8.2.50.0040.00418.16
8.2.40.0000.00817.89
8.2.30.0040.00418.15
8.2.20.0000.00720.49
8.2.10.0000.00717.79
8.2.00.0030.00719.17
8.1.300.0070.00315.86
8.1.290.0080.00418.88
8.1.280.0120.00325.92
8.1.270.0040.00423.99
8.1.260.0000.00926.35
8.1.250.0070.00028.09
8.1.240.0040.00423.92
8.1.230.0090.00322.50
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0000.00917.35
8.1.190.0080.00017.35
8.1.180.0000.00818.10
8.1.170.0030.00617.62
8.1.160.0040.00418.86
8.1.150.0070.00018.62
8.1.140.0030.00517.47
8.1.130.0000.00718.80
8.1.120.0030.00517.52
8.1.110.0040.00417.45
8.1.100.0080.00017.48
8.1.90.0000.00717.40
8.1.80.0030.00617.48
8.1.70.0050.00317.51
8.1.60.0080.00017.46
8.1.50.0050.00317.37
8.1.40.0070.00317.53
8.1.30.0090.00417.52
8.1.20.0060.00517.56
8.1.10.0090.00417.49
8.1.00.0050.00517.46
8.0.300.0000.00720.16
8.0.290.0040.00416.63
8.0.280.0000.00718.44
8.0.270.0070.00017.16
8.0.260.0060.00318.50
8.0.250.0030.00316.82
8.0.240.0040.00416.95
8.0.230.0040.00416.98
8.0.220.0040.00416.90
8.0.210.0040.00416.74
8.0.200.0040.00416.90
8.0.190.0050.00216.95
8.0.180.0070.00316.89
8.0.170.0000.00916.87
8.0.160.0050.00616.80
8.0.150.0080.00216.74
8.0.140.0040.00616.75
8.0.130.0050.00516.76
8.0.120.0070.00316.83
8.0.110.0020.00816.76
8.0.100.0000.00916.86
8.0.90.0080.00416.79
8.0.80.0060.00516.87
8.0.70.0020.00816.85
8.0.60.0050.00416.77
8.0.50.0050.00516.76
8.0.30.0070.00216.81
8.0.20.0050.00516.81
8.0.10.0080.00416.89
7.4.330.0000.00715.55
7.4.320.0020.00516.57
7.4.300.0000.00616.60
7.4.290.0080.00316.31
7.4.280.0130.00316.59
7.4.270.0020.00816.43
7.4.260.0040.00616.50
7.4.250.0060.00616.43
7.4.240.0090.00516.59
7.4.230.0060.00616.37
7.4.220.0070.00616.42
7.4.210.0000.00816.43
7.4.200.0030.00616.53
7.4.190.0030.00516.54
7.4.180.0060.00316.63
7.4.160.0050.00416.59
7.4.150.0060.00216.43
7.4.140.0000.00916.33
7.4.130.0060.00316.39
7.4.120.0080.00216.48
7.4.110.0020.00816.36
7.4.100.0090.00216.41
7.4.90.0050.00516.45
7.4.80.0060.00416.46
7.4.70.0070.00116.41
7.4.60.0040.00416.47
7.4.50.0050.00416.29
7.4.40.0030.00516.28
7.4.30.0080.00016.31
7.4.20.0070.00216.44
7.4.10.0060.00216.43
7.4.00.0010.00816.47

preferences:
60.13 ms | 403 KiB | 5 Q