3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "we test coders"; echo reverse_word($str) . "\n"; function reverse_word($input) { $num_ws = 0; $p = 0; while(strpos($input, " ", $p) !== false) { $num_ws ++; $p = strpos($input, ' ', $p) + 1; } //echo "num ws is $num_ws\n"; $p = 0; for($i=0; $i<$num_ws + 1; $i++) { $ws_index = strpos($input, " ", $p); if($ws_index === false) { $word = substr($input, $p); } else { $length = $ws_index - $p; $word = substr($input, $p, $length); } $result[] = $word; $p = $ws_index + 1; //move onto first char of next word } print_r($result); $str = ''; for($i=0; $i<count($result); $i++) { $str .= reverse($result[$i]) . " "; } //return $str; } function reverse($str) { $a = 0; $b = strlen($str)-1; while($a < $b) { swap($str, $a, $b); $a ++; $b --; } return $str; } function swap(&$str, $i1, $i2) { $tmp = $str[$i1]; $str[$i1] = $str[$i2]; $str[$i2] = $tmp; } ?>

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.0120.00318.30
8.3.50.0090.00921.25
8.3.40.0140.00319.02
8.3.30.0040.01119.13
8.3.20.0000.00720.34
8.3.10.0040.00423.61
8.3.00.0060.00323.57
8.2.180.0040.01216.50
8.2.170.0120.00322.96
8.2.160.0100.00322.26
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0070.00417.88
8.2.110.0060.00322.11
8.2.100.0050.00917.63
8.2.90.0080.00019.17
8.2.80.0080.00017.97
8.2.70.0030.00617.75
8.2.60.0030.00617.93
8.2.50.0030.00618.07
8.2.40.0030.00621.10
8.2.30.0030.00518.23
8.2.20.0040.00417.89
8.2.10.0000.00818.20
8.2.00.0040.00418.03
8.1.280.0110.00725.92
8.1.270.0080.00020.25
8.1.260.0070.00026.35
8.1.250.0030.00628.09
8.1.240.0040.00421.27
8.1.230.0090.00317.89
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0030.00617.35
8.1.190.0050.00317.13
8.1.180.0040.00418.10
8.1.170.0080.00018.46
8.1.160.0000.00822.04
8.1.150.0040.00418.88
8.1.140.0000.00717.39
8.1.130.0000.00717.71
8.1.120.0000.00717.52
8.1.110.0000.00817.47
8.1.100.0030.00517.41
8.1.90.0050.00217.43
8.1.80.0040.00417.51
8.1.70.0050.00217.43
8.1.60.0000.00817.56
8.1.50.0000.00817.48
8.1.40.0030.00617.54
8.1.30.0080.00017.62
8.1.20.0030.00617.70
8.1.10.0050.00217.57
8.1.00.0040.00417.52
8.0.300.0060.00918.77
8.0.290.0040.00416.75
8.0.280.0070.00018.51
8.0.270.0000.00717.27
8.0.260.0030.00317.18
8.0.250.0040.00416.94
8.0.240.0030.00316.93
8.0.230.0070.00016.96
8.0.220.0000.00816.89
8.0.210.0040.00417.02
8.0.200.0060.00317.03
8.0.190.0080.00016.95
8.0.180.0000.00717.06
8.0.170.0000.00816.91
8.0.160.0000.00716.83
8.0.150.0040.00416.91
8.0.140.0050.00316.78
8.0.130.0000.00813.36
8.0.120.0050.00316.98
8.0.110.0040.00416.99
8.0.100.0000.00816.86
8.0.90.0000.00816.89
8.0.80.0120.00316.93
8.0.70.0040.00416.85
8.0.60.0020.00516.88
8.0.50.0070.00017.01
8.0.30.0130.00617.19
8.0.20.0140.00817.40
8.0.10.0050.00316.97
8.0.00.0110.00816.93
7.4.330.0000.00515.08
7.4.320.0000.00716.59
7.4.300.0000.00616.68
7.4.290.0030.00316.64
7.4.280.0070.00416.58
7.4.270.0000.00716.54
7.4.260.0000.00716.55
7.4.250.0030.00316.52
7.4.240.0030.00416.59
7.4.230.0030.00316.58
7.4.220.0070.01316.75
7.4.210.0120.00316.57
7.4.200.0050.00316.55
7.4.160.0040.01216.44
7.4.150.0090.01317.40
7.4.140.0100.01217.86
7.4.130.0110.00516.51
7.4.120.0130.00516.48
7.4.110.0030.01416.47
7.4.100.0150.00416.43
7.4.90.0130.01016.47
7.4.80.0090.00919.39
7.4.70.0110.00616.53
7.4.60.0160.00016.64
7.4.50.0040.00416.40
7.4.40.0060.00916.54
7.4.30.0060.01016.48
7.4.00.0120.00515.12
7.3.330.0040.00413.23
7.3.320.0030.00313.38
7.3.310.0030.00516.44
7.3.300.0030.00316.23
7.3.290.0060.00816.36
7.3.280.0120.00716.43
7.3.270.0130.00317.40
7.3.260.0140.01116.66
7.3.250.0090.01016.43
7.3.240.0100.01016.58
7.3.230.0090.00916.39
7.3.210.0150.00316.61
7.3.200.0040.01516.50
7.3.190.0130.00616.63
7.3.180.0000.01616.55
7.3.170.0100.00716.61
7.3.160.0140.00616.48
7.3.120.0060.01214.85
7.3.110.0100.01014.68
7.3.100.0060.00915.04
7.3.90.0060.00914.62
7.3.80.0070.01014.85
7.3.70.0130.00614.84
7.3.60.0090.00615.06
7.3.50.0060.01215.07
7.3.40.0070.01015.04
7.3.30.0030.00614.72
7.3.20.0030.00916.61
7.3.10.0000.01316.55
7.3.00.0030.01516.69
7.2.330.0080.01016.77
7.2.320.0070.01116.47
7.2.310.0090.01016.52
7.2.300.0120.00316.86
7.2.290.0060.01116.84
7.2.250.0110.00715.27
7.2.240.0100.01015.05
7.2.230.0040.01115.09
7.2.220.0090.01214.83
7.2.210.0110.01115.23
7.2.200.0000.01415.02
7.2.190.0160.00015.21
7.2.180.0160.00315.23
7.2.170.0000.01715.13
7.2.160.0000.01515.00
7.2.150.0090.00616.93
7.2.140.0030.01117.04
7.2.130.0040.01416.76
7.2.120.0110.00316.99
7.2.110.0040.00916.95
7.2.100.0070.01117.00
7.2.90.0030.00916.81
7.2.80.0090.00616.91
7.2.70.0030.01317.09
7.2.60.0040.01116.92
7.2.50.0030.00616.96
7.2.40.0120.00317.13
7.2.30.0000.01617.11
7.2.20.0000.01417.00
7.2.10.0080.00416.97
7.2.00.0050.00818.23
7.1.330.0100.00715.77
7.1.320.0100.00316.00
7.1.310.0060.01215.93
7.1.300.0030.01215.62
7.1.290.0060.00615.57
7.1.280.0000.01315.64
7.1.270.0040.01116.00
7.1.260.0060.00615.66
7.1.250.0050.00815.85
7.1.240.0040.00415.64
7.1.230.0090.00615.89
7.1.220.0100.00715.72
7.1.210.0130.00015.78
7.1.200.0030.01315.84
7.1.190.0090.00315.85
7.1.180.0030.01315.85
7.1.170.0070.00415.80
7.1.160.0040.00715.77
7.1.150.0100.00415.91
7.1.140.0070.00715.79
7.1.130.0000.00715.75
7.1.120.0000.01715.81
7.1.110.0080.00415.86
7.1.100.0050.00616.95
7.1.90.0100.00315.86
7.1.80.0060.00915.63
7.1.70.0080.00416.57
7.1.60.0060.00517.67
7.1.50.0080.00716.54
7.1.40.0100.00315.86
7.1.30.0040.01115.45
7.1.20.0070.00715.74
7.1.10.0110.00015.96
7.1.00.0040.04419.15
7.0.330.0100.00315.61
7.0.320.0130.00015.36
7.0.310.0040.00715.14
7.0.300.0030.00715.45
7.0.290.0060.00615.38
7.0.280.0040.00415.42
7.0.270.0000.00915.37
7.0.260.0030.01315.54
7.0.250.0000.00815.54
7.0.240.0030.01015.11
7.0.230.0100.00315.57
7.0.220.0030.00915.33
7.0.210.0070.00415.57
7.0.200.0170.00515.23
7.0.190.0000.01315.48
7.0.180.0060.00615.49
7.0.170.0080.00415.23
7.0.160.0030.00515.61
7.0.150.0050.00515.32
7.0.140.0030.01015.45
7.0.130.0070.00715.58
7.0.120.0110.00315.33
7.0.110.0070.02117.78
7.0.100.0070.03517.64
7.0.90.0150.01617.78
7.0.80.0030.04217.75
7.0.70.0090.03817.68
7.0.60.0020.02817.74
7.0.50.0060.02317.64
7.0.40.0050.02416.76
7.0.30.0040.02216.73
7.0.20.0070.02016.66
7.0.10.0070.04016.57
7.0.00.0030.02416.59
5.6.400.0080.00614.72
5.6.390.0130.00314.76
5.6.380.0070.01114.67
5.6.370.0070.00714.68
5.6.360.0040.01114.03
5.6.350.0030.00914.71
5.6.340.0030.00614.45
5.6.330.0060.00314.44
5.6.320.0040.00914.36
5.6.310.0060.00614.17
5.6.300.0060.00614.42
5.6.290.0030.00714.53
5.6.280.0030.02417.79
5.6.270.0000.01114.21
5.6.260.0060.02217.64
5.6.250.0050.03217.61
5.6.240.0030.04117.53
5.6.230.0030.03417.60
5.6.220.0070.02717.51
5.6.210.0090.02217.52
5.6.200.0060.02617.51
5.6.190.0050.04217.54
5.6.180.0030.03817.57
5.6.170.0110.03317.54
5.6.160.0080.03017.42
5.6.150.0120.03317.65
5.6.140.0090.04117.66
5.6.130.0050.02717.42
5.6.120.0050.03817.57
5.6.110.0070.03817.46
5.6.100.0070.02417.57
5.6.90.0020.02317.46
5.6.80.0030.02216.98
5.6.70.0070.02217.06
5.6.60.0030.04317.24
5.6.50.0100.03817.23
5.6.40.0030.02617.09
5.6.30.0030.02317.21
5.6.20.0030.02817.22
5.6.10.0050.03317.26
5.6.00.0080.04017.14
5.5.380.0040.02416.10
5.5.370.0050.01816.00
5.5.360.0050.04016.03
5.5.350.0020.03716.19
5.5.340.0030.03316.34
5.5.330.0080.02916.42
5.5.320.0030.03516.27
5.5.310.0050.02516.37
5.5.300.0030.03316.15
5.5.290.0080.03316.18
5.5.280.0100.04416.19
5.5.270.0030.03916.25
5.5.260.0060.02316.23
5.5.250.0100.02316.12
5.5.240.0060.03315.95
5.5.230.0030.02515.81
5.5.220.0080.04015.94
5.5.210.0020.04015.88
5.5.200.0050.02815.81
5.5.190.0080.04015.84
5.5.180.0100.03815.96
5.5.170.0040.00714.22
5.5.160.0050.02816.00
5.5.150.0080.04115.84
5.5.140.0050.04016.00
5.5.130.0050.03415.84
5.5.120.0080.02016.10
5.5.110.0020.04415.84
5.5.100.0040.03915.82
5.5.90.0070.01615.81
5.5.80.0070.02215.75
5.5.70.0050.02715.94
5.5.60.0040.02015.73
5.5.50.0120.03515.91
5.5.40.0100.03715.89
5.5.30.0050.02715.89
5.5.20.0060.03915.75
5.5.10.0030.02015.63
5.5.00.0080.02015.77
5.4.450.0030.02516.16
5.4.440.0140.03616.19
5.4.430.0030.02216.28
5.4.420.0030.03316.19
5.4.410.0050.02816.29
5.4.400.0050.02016.15
5.4.390.0080.03716.15
5.4.380.0030.02016.04
5.4.370.0020.03016.02
5.4.360.0060.02516.11
5.4.350.0050.03216.18
5.4.340.0020.03116.01
5.4.330.0030.00813.05
5.4.320.0030.04016.04
5.4.310.0080.03816.11
5.4.300.0100.02816.01
5.4.290.0050.03216.03
5.4.280.0030.03616.12
5.4.270.0020.04516.02
5.4.260.0030.03916.15
5.4.250.0000.02316.07
5.4.240.0070.01516.09
5.4.230.0030.03516.00
5.4.220.0060.02716.06
5.4.210.0050.01616.09
5.4.200.0030.02216.00
5.4.190.0050.04016.01
5.4.180.0030.04116.03
5.4.170.0050.01815.99
5.4.160.0010.02916.19
5.4.150.0070.02015.99
5.4.140.0050.02214.70
5.4.130.0070.01914.80
5.4.120.0070.01714.74
5.4.110.0020.02314.88
5.4.100.0050.02014.76
5.4.90.0020.01814.84
5.4.80.0000.02114.70
5.4.70.0050.02114.75
5.4.60.0050.02014.75
5.4.50.0060.01914.67
5.4.40.0030.02214.74
5.4.30.0050.01714.79
5.4.20.0060.02214.69
5.4.10.0030.01714.79
5.4.00.0000.02514.43
5.3.290.0000.05314.64
5.3.280.0130.03014.84
5.3.270.0000.04014.62
5.3.260.0070.03314.71
5.3.250.0030.04014.60
5.3.240.0030.03314.77
5.3.230.0030.03714.62
5.3.220.0000.06014.56
5.3.210.0000.04314.54
5.3.200.0100.03014.73
5.3.190.0030.04014.60
5.3.180.0030.03714.66
5.3.170.0000.04714.60
5.3.160.0070.03314.54
5.3.150.0030.03314.58
5.3.140.0030.05714.70
5.3.130.0070.03714.56
5.3.120.0070.04314.55
5.3.110.0070.03314.65
5.3.100.0070.03714.18
5.3.90.0000.04014.17
5.3.80.0000.04014.13
5.3.70.0000.03714.12
5.3.60.0030.03714.11
5.3.50.0000.03314.10
5.3.40.0000.04014.09
5.3.30.0030.03313.92
5.3.20.0030.03013.72
5.3.10.0030.03313.90
5.3.00.0030.02713.88
5.2.170.0030.02711.93
5.2.160.0000.03311.93
5.2.150.0000.03311.93
5.2.140.0000.02711.93
5.2.130.0000.03311.93
5.2.120.0030.02311.93
5.2.110.0000.03011.93
5.2.100.0000.03011.93
5.2.90.0030.02711.93
5.2.80.0000.02711.93
5.2.70.0000.03011.93
5.2.60.0070.02011.93
5.2.50.0070.02011.93
5.2.40.0000.02711.93
5.2.30.0000.02711.93
5.2.20.0000.02711.93
5.2.10.0030.02311.93
5.2.00.0070.02011.93
5.1.60.0030.01711.93
5.1.50.0000.02311.93
5.1.40.0030.03711.93
5.1.30.0100.05011.93
5.1.20.0030.03011.95
5.1.10.0030.02011.95
5.1.00.0070.04311.95
5.0.50.0000.03711.95
5.0.40.0030.04011.95
5.0.30.0000.03311.95
5.0.20.0000.03011.95
5.0.10.0000.04711.95
5.0.00.0100.04011.95
4.4.90.0000.01311.93
4.4.80.0000.01311.93
4.4.70.0000.01311.93
4.4.60.0070.00711.93
4.4.50.0000.01311.93
4.4.40.0000.02011.93
4.4.30.0000.03711.93
4.4.20.0000.02011.95
4.4.10.0000.02011.95
4.4.00.0000.03011.95
4.3.110.0000.01311.95
4.3.100.0000.01711.95
4.3.90.0030.01311.95
4.3.80.0030.05011.95
4.3.70.0070.02311.95
4.3.60.0070.03011.95
4.3.50.0030.03311.95
4.3.40.0030.03711.95
4.3.30.0000.03311.95
4.3.20.0030.03311.95
4.3.10.0030.02711.95
4.3.00.0030.02711.95

preferences:
63.65 ms | 401 KiB | 5 Q