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.0110.00418.38
8.3.50.0050.01421.26
8.3.40.0090.00918.76
8.3.30.0070.00719.20
8.3.20.0040.00420.38
8.3.10.0110.00323.48
8.3.00.0060.00323.71
8.2.180.0060.00916.63
8.2.170.0070.00722.96
8.2.160.0030.01022.21
8.2.150.0030.00624.18
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0060.00317.85
8.2.110.0140.00722.00
8.2.100.0090.00317.75
8.2.90.0050.00319.33
8.2.80.0040.00417.97
8.2.70.0030.00517.63
8.2.60.0080.00018.05
8.2.50.0040.00418.07
8.2.40.0040.00421.11
8.2.30.0000.00718.05
8.2.20.0020.00517.89
8.2.10.0000.00818.02
8.2.00.0000.00818.23
8.1.280.0100.01025.92
8.1.270.0040.00420.39
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0090.00021.36
8.1.230.0040.00717.89
8.1.220.0040.00417.74
8.1.210.0080.00018.77
8.1.200.0030.00617.47
8.1.190.0000.00917.23
8.1.180.0000.00818.10
8.1.170.0000.00920.43
8.1.160.0000.00721.91
8.1.150.0000.00718.92
8.1.140.0030.00517.36
8.1.130.0050.00317.74
8.1.120.0040.00417.49
8.1.110.0000.00717.38
8.1.100.0030.00517.50
8.1.90.0030.00317.37
8.1.80.0000.00817.48
8.1.70.0000.00817.38
8.1.60.0030.00617.53
8.1.50.0000.00917.55
8.1.40.0080.00017.47
8.1.30.0000.00817.42
8.1.20.0000.00817.61
8.1.10.0040.00417.56
8.1.00.0000.00717.49
8.0.300.0000.01018.77
8.0.290.0040.00416.75
8.0.280.0030.00318.44
8.0.270.0000.00817.20
8.0.260.0040.00417.20
8.0.250.0000.00716.97
8.0.240.0000.00716.97
8.0.230.0000.00716.93
8.0.220.0030.00316.98
8.0.210.0040.00416.97
8.0.200.0030.00717.12
8.0.190.0040.00417.03
8.0.180.0030.00516.89
8.0.170.0040.00517.01
8.0.160.0070.00016.99
8.0.150.0030.00516.95
8.0.140.0070.00016.83
8.0.130.0000.00813.47
8.0.120.0000.00816.87
8.0.110.0080.00017.02
8.0.100.0000.00717.04
8.0.90.0040.00416.87
8.0.80.0040.01117.01
8.0.70.0000.00817.02
8.0.60.0040.00417.02
8.0.50.0040.00416.93
8.0.30.0090.00917.09
8.0.20.0170.00317.40
8.0.10.0050.00316.95
8.0.00.0030.01516.85
7.4.330.0050.00015.08
7.4.320.0030.00316.60
7.4.300.0030.00316.55
7.4.290.0070.00016.68
7.4.280.0030.00916.67
7.4.270.0050.00316.66
7.4.260.0000.00816.62
7.4.250.0000.00816.43
7.4.240.0040.00316.65
7.4.230.0030.00316.47
7.4.220.0060.01216.55
7.4.210.0000.01416.66
7.4.200.0000.00716.43
7.4.160.0100.00516.41
7.4.150.0100.00717.40
7.4.140.0140.00617.86
7.4.130.0100.00716.51
7.4.120.0100.01016.67
7.4.110.0130.00316.56
7.4.100.0100.01316.64
7.4.90.0000.01816.58
7.4.80.0100.00619.39
7.4.70.0100.01316.42
7.4.60.0060.00916.66
7.4.50.0000.00516.63
7.4.40.0060.01116.34
7.4.30.0040.01216.46
7.4.10.0130.00615.20
7.4.00.0090.00915.16
7.3.330.0070.00013.18
7.3.320.0000.00513.36
7.3.310.0000.00716.57
7.3.300.0070.00016.41
7.3.290.0040.01116.38
7.3.280.0120.00716.40
7.3.270.0120.00417.40
7.3.260.0060.01716.59
7.3.250.0120.00816.35
7.3.240.0130.00616.60
7.3.230.0070.01416.46
7.3.210.0140.00416.72
7.3.200.0140.01116.64
7.3.190.0030.01316.57
7.3.180.0090.00616.49
7.3.170.0110.00816.57
7.3.160.0070.01716.52
7.3.130.0030.01615.20
7.3.120.0040.01415.20
7.3.110.0130.00615.20
7.3.100.0110.00415.20
7.3.90.0030.00615.20
7.3.80.0060.00315.20
7.3.70.0000.00815.20
7.3.60.0070.00715.20
7.3.50.0060.01015.20
7.3.40.0140.00415.20
7.3.30.0110.00415.20
7.3.20.0070.00316.79
7.3.10.0080.00816.75
7.3.00.0030.00616.51
7.2.330.0130.00316.59
7.2.320.0100.00716.53
7.2.310.0070.01016.47
7.2.300.0030.01416.91
7.2.290.0130.00316.76
7.2.260.0040.01515.20
7.2.250.0110.00615.20
7.2.240.0070.00715.20
7.2.230.0090.00915.20
7.2.220.0060.00715.32
7.2.210.0040.00815.37
7.2.200.0080.00815.20
7.2.190.0030.00915.21
7.2.180.0090.00615.20
7.2.170.0080.01115.20
7.2.160.0030.01215.23
7.2.150.0000.01617.05
7.2.140.0040.01516.95
7.2.130.0070.00617.04
7.2.120.0100.00616.65
7.2.110.0000.01216.93
7.2.100.0030.00617.08
7.2.90.0060.00916.99
7.2.80.0030.00617.09
7.2.70.0060.00316.79
7.2.60.0030.01017.10
7.2.50.0060.00616.86
7.2.40.0030.00916.87
7.2.30.0030.01317.05
7.2.20.0080.00817.09
7.2.10.0050.00517.00
7.2.00.0030.00916.85
7.1.330.0070.00715.75
7.1.320.0100.00715.88
7.1.310.0030.00915.81
7.1.300.0000.01616.00
7.1.290.0000.01515.69
7.1.280.0090.00015.88
7.1.270.0030.00715.65
7.1.260.0100.00315.84
7.1.250.0100.00315.83
7.1.240.0070.01015.52
7.1.230.0070.00715.89
7.1.220.0050.00315.81
7.1.210.0110.00415.73
7.1.200.0080.00815.62
7.1.190.0060.01015.93
7.1.180.0000.01215.74
7.1.170.0000.00915.52
7.1.160.0090.00615.64
7.1.150.0000.01615.77
7.1.140.0050.00315.54
7.1.130.0040.00715.97
7.1.120.0080.00615.93
7.1.110.0060.00315.92
7.1.100.0030.00515.82
7.1.90.0000.00915.68
7.1.80.0060.00615.82
7.1.70.0050.00516.43
7.1.60.0050.01017.68
7.1.50.0100.00316.37
7.1.40.0030.00616.03
7.1.30.0090.00615.59
7.1.20.0090.00615.90
7.1.10.0000.00915.73
7.1.00.0060.04019.08
7.0.330.0040.00415.36
7.0.320.0030.01015.54
7.0.310.0000.00815.36
7.0.300.0030.00615.47
7.0.290.0030.00615.23
7.0.280.0000.00915.59
7.0.270.0080.00315.59
7.0.260.0060.00615.20
7.0.250.0070.00315.35
7.0.240.0040.00715.57
7.0.230.0000.00915.60
7.0.220.0030.01015.64
7.0.210.0000.01715.39
7.0.200.0100.00715.12
7.0.190.0000.00815.51
7.0.180.0040.00715.50
7.0.170.0090.00315.46
7.0.160.0040.00715.52
7.0.150.0030.00915.39
7.0.140.0000.01015.34
7.0.130.0000.01015.61
7.0.120.0040.01115.30
7.0.110.0060.00615.30
7.0.100.0070.00715.48
7.0.90.0100.00715.54
7.0.80.0070.00715.33
7.0.70.0030.01015.46
7.0.60.0080.04217.76
7.0.50.0080.02316.71
7.0.40.0050.02317.72
7.0.30.0150.02817.75
7.0.20.0150.03817.70
7.0.10.0050.02617.68
7.0.00.0020.02617.63
5.6.400.0150.00415.20
5.6.390.0000.01215.20
5.6.380.0060.00915.20
5.6.370.0030.00715.20
5.6.360.0030.00915.20
5.6.350.0040.00715.20
5.6.340.0120.00315.20
5.6.330.0030.01015.20
5.6.320.0040.01115.20
5.6.310.0100.00615.20
5.6.300.0090.00615.20
5.6.290.0110.00015.20
5.6.280.0070.03318.17
5.6.270.0080.00615.20
5.6.260.0030.01715.20
5.6.250.0030.01315.20
5.6.240.0080.00515.20
5.6.230.0060.00915.20
5.6.220.0090.00615.20
5.6.210.0070.02617.93
5.6.200.0030.02316.68
5.6.190.0080.02317.86
5.6.180.0230.02517.86
5.6.170.0180.02517.87
5.6.160.0030.02617.82
5.6.150.0030.03216.71
5.6.140.0070.02716.72
5.6.130.0140.03716.72
5.6.120.0120.03018.09
5.6.110.0060.04518.10
5.6.100.0070.03518.05
5.6.90.0030.04318.14
5.6.80.0080.03517.85
5.6.70.0040.01115.20
5.6.60.0030.00915.20
5.6.50.0130.00015.20
5.6.40.0070.00715.20
5.6.30.0040.00815.20
5.6.20.0070.00715.20
5.6.10.0060.00615.20
5.6.00.0040.00715.20
5.5.380.0070.01115.20
5.5.370.0040.00415.20
5.5.360.0030.01015.20
5.5.350.0100.04117.86
5.5.340.0060.05016.59
5.5.330.0050.04517.77
5.5.320.0030.02317.77
5.5.310.0160.02617.72
5.5.300.0140.03916.58
5.5.290.0120.04016.58
5.5.280.0120.04317.93
5.5.270.0050.04118.02
5.5.260.0100.02317.99
5.5.250.0070.04417.88
5.5.240.0180.03817.64
5.5.230.0000.00815.20
5.5.220.0000.01315.20
5.5.210.0070.00715.20
5.5.200.0130.00015.20
5.5.190.0060.00315.20
5.5.180.0060.00615.20
5.5.170.0060.00615.20
5.5.160.0070.00715.20
5.5.150.0040.00415.20
5.5.140.0030.01315.20
5.5.130.0060.00815.20
5.5.120.0040.00815.20
5.5.110.0000.01115.20
5.5.100.0090.00315.20
5.5.90.0080.00415.20
5.5.80.0120.00315.20
5.5.70.0030.01015.20
5.5.60.0070.00315.20
5.5.50.0070.01015.20
5.5.40.0060.00615.20
5.5.30.0080.00815.20
5.5.20.0030.01015.20
5.5.10.0070.00715.20
5.5.00.0070.00415.20
5.4.450.0350.03017.19
5.4.440.0370.03817.20
5.4.430.0320.03717.33
5.4.420.0350.03617.40
5.4.410.0330.03017.35
5.4.400.0420.03317.11
5.4.390.0330.03117.17
5.4.380.0270.03517.17
5.4.370.0280.03817.10
5.4.360.0130.03017.24
5.4.350.0300.03517.02
5.4.340.0370.03317.16
5.4.330.0040.00715.20
5.4.320.0100.03017.25
5.4.310.0070.03117.29
5.4.300.0200.03017.24
5.4.290.0350.02817.23
5.4.280.0400.04217.24
5.4.270.0420.03417.15
5.4.260.0150.02817.16
5.4.250.0100.04217.15
5.4.240.0050.03917.20
5.4.230.0410.02717.13
5.4.220.0450.04517.21
5.4.210.0350.03117.08
5.4.200.0360.02315.98
5.4.190.0400.03217.24
5.4.180.0420.02917.09
5.4.170.0360.03117.04
5.4.160.0460.02817.05
5.4.150.0270.03317.16
5.4.140.0300.02715.90
5.4.130.0300.02815.87
5.4.120.0320.02315.78
5.4.110.0320.02915.89
5.4.100.0350.02815.90
5.4.90.0300.03015.79
5.4.80.0360.02515.83
5.4.70.0370.02816.00
5.4.60.0280.02815.85
5.4.50.0350.02415.74
5.4.40.0330.02615.87
5.4.30.0400.02815.86
5.4.20.0450.02215.74
5.4.10.0380.03015.82
5.4.00.0380.02815.49
5.3.290.0770.06314.73
5.3.280.0700.08014.52
5.3.270.0730.08014.72
5.3.260.0770.08714.71
5.3.250.0670.05714.53
5.3.240.0870.05314.67
5.3.230.0800.04314.52
5.3.220.0700.05014.73
5.3.210.0600.06014.60
5.3.200.0600.05014.50
5.3.190.0870.04714.49
5.3.180.0770.05314.49
5.3.170.0800.08014.48
5.3.160.0830.07014.49
5.3.150.0800.05714.49
5.3.140.0770.05314.59
5.3.130.0730.06314.66
5.3.120.0770.05014.61
5.3.110.0830.04314.55
5.3.100.0700.05713.96
5.3.90.0870.04314.05
5.3.80.0870.04013.94
5.3.70.0730.07714.18
5.3.60.0670.06713.92
5.3.50.0700.05313.89
5.3.40.0770.05313.82
5.3.30.0730.05313.84
5.3.20.0730.06013.64
5.3.10.0670.04313.68
5.3.00.0630.05713.55
5.2.170.0470.06311.08
5.2.160.0100.04011.04
5.2.150.0130.05311.32
5.2.140.0130.04011.07
5.2.130.0270.05711.05
5.2.120.0630.04711.18
5.2.110.0870.05011.18
5.2.100.0600.04711.14
5.2.90.0670.04311.06
5.2.80.0700.04011.18
5.2.70.0830.04711.27
5.2.60.0870.05011.10
5.2.50.0730.04711.10
5.2.40.0530.03710.88
5.2.30.0600.05310.90
5.2.20.0630.03011.14
5.2.10.0500.04710.89
5.2.00.0430.04710.97
5.1.60.0530.0379.89
5.1.50.0600.04310.00
5.1.40.0530.0339.92
5.1.30.0530.04710.58
5.1.20.0470.04010.29
5.1.10.0470.03310.02
5.1.00.0600.03710.07
5.0.50.0230.0338.64
5.0.40.0300.0278.52
5.0.30.0230.0638.18
5.0.20.0270.0378.13
5.0.10.0400.0308.25
5.0.00.0200.0478.41
4.4.90.0230.0335.80
4.4.80.0300.0335.96
4.4.70.0270.0205.87
4.4.60.0270.0305.88
4.4.50.0230.0275.85
4.4.40.0270.0335.85
4.4.30.0400.0135.92
4.4.20.0200.0205.95
4.4.10.0300.0205.93
4.4.00.0300.0375.82
4.3.110.0300.0235.80
4.3.100.0370.0205.72
4.3.90.0270.0305.77
4.3.80.0270.0375.71
4.3.70.0230.0235.80
4.3.60.0300.0235.70
4.3.50.0300.0205.77
4.3.40.0300.0475.66
4.3.30.0100.0274.58
4.3.20.0130.0204.54
4.3.10.0100.0234.49
4.3.00.0100.0237.21

preferences:
66.03 ms | 401 KiB | 5 Q