3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wordsToArr($str) { $words =[]; $ex_str =explode(' ',$str); foreach ($ex_str as $k=>$v) { $words[] =implode(' ',$ex_str); unset($ex_str[$k]); } return $words; } function wordsToArr2($str) { $words = [$str]; while ($pos =strpos ( $str , ' ')) { $str=substr($str,($pos+1)); $words[] =$str; } return $words; } function wordsToArr3($str) { $base = array_reverse(explode(' ', $str)); $words = [$placeholder = array_shift($base)]; foreach ($base as $word) { $words[] = $placeholder = $word . ' ' . $placeholder; } return array_reverse($words); } $sentence = 'The quick brown fox jumps over the lazy dog'; $now = microtime(true); for ($i=0;$i<100;$i++) { wordsToArr($sentence); } $end = microtime(true); echo 'implode '. $i .' times in: ' . number_format($end - $now, 8) . '/sec' . PHP_EOL; $now = microtime(true); for ($i=0;$i<100;$i++) { wordsToArr2($sentence); } $end = microtime(true); echo 'strpos '. $i .' times in: ' . number_format($end - $now, 8) . '/sec' . PHP_EOL; $now = microtime(true); for ($i=0;$i<100;$i++) { wordsToArr3($sentence); } $end = microtime(true); echo 'concat '. $i .' times in: ' . number_format($end - $now, 8) . '/sec' . PHP_EOL;

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)
7.4.10.0060.01215.32
7.4.00.0070.01114.96
7.3.130.0070.01115.32
7.3.120.0080.00914.91
7.3.110.0100.00914.95
7.3.100.0040.01114.99
7.3.90.0040.01014.93
7.3.80.0050.00815.03
7.3.70.0070.01214.97
7.3.60.0060.00815.04
7.3.50.0040.01214.81
7.3.40.0070.00714.98
7.3.30.0070.00614.98
7.3.20.0090.00716.59
7.3.10.0050.00816.53
7.3.00.0050.00916.58
7.2.260.0030.01615.32
7.2.250.0050.01315.17
7.2.240.0060.01415.08
7.2.230.0050.01015.04
7.2.220.0060.01015.23
7.2.210.0070.01115.24
7.2.200.0090.01115.14
7.2.190.0000.01415.11
7.2.180.0080.00815.20
7.2.170.0080.00715.12
7.2.160.0110.00415.32
7.2.150.0000.01317.00
7.2.140.0110.00316.96
7.2.130.0090.00617.00
7.2.120.0070.00716.96
7.2.110.0480.00515.90
7.2.100.0550.00515.95
7.2.90.0400.00915.90
7.2.80.0520.01215.90
7.2.70.0460.00715.77
7.2.60.0520.00515.88
7.2.50.0440.01115.92
7.2.40.0540.00916.12
7.2.30.0400.01216.07
7.2.20.0440.00615.87
7.2.10.0350.00616.07
7.2.00.0560.00315.85
7.1.330.0080.00715.86
7.1.320.0060.00715.85
7.1.310.0070.00915.72
7.1.300.0050.00815.81
7.1.290.0060.00715.54
7.1.280.0070.01015.69
7.1.270.0050.01015.73
7.1.260.0090.00615.77
7.1.250.0060.00915.75
7.1.240.0030.00915.96
7.1.230.0530.00614.96
7.1.220.0370.01114.71
7.1.210.0440.00714.71
7.1.200.0350.00814.95
7.1.190.0530.00514.81
7.1.180.0510.00314.67
7.1.170.0410.00714.66
7.1.160.0440.00914.82
7.1.150.0440.00714.83
7.1.140.0300.01214.97
7.1.130.0470.00515.06
7.1.120.0340.01514.97
7.1.110.0380.00614.76
7.1.100.0330.00814.82
7.1.90.0460.00814.79
7.1.80.0320.01014.92
7.1.70.0390.00514.79
7.1.60.0490.00523.78
7.1.50.0410.01123.73
7.1.40.0340.01323.73
7.1.30.0500.01323.95
7.1.20.0410.01223.85
7.1.10.0290.00614.85
7.1.00.0280.00614.76
7.0.330.0030.01315.38
7.0.320.0000.00915.56
7.0.310.0000.01615.32
7.0.300.0060.00615.44
7.0.290.0090.00315.42
7.0.280.0090.00615.52
7.0.270.0070.01015.42
7.0.260.0030.00915.34
7.0.250.0060.00915.61
7.0.240.0070.00715.40
7.0.230.0140.00315.49
7.0.220.0070.00715.37
7.0.210.0030.01315.36
7.0.200.0030.01315.42
7.0.190.0040.00715.36
7.0.180.0060.00915.65
7.0.170.0030.00915.53
7.0.160.0070.00315.46
7.0.150.0040.01115.64
7.0.140.0070.00315.58
7.0.130.0090.00915.57
7.0.120.0000.01415.59
7.0.110.0000.01515.32
7.0.100.0030.01015.49
7.0.90.0030.00615.32
7.0.80.0070.00715.43
7.0.70.0060.00915.61
7.0.60.0070.01015.66
7.0.50.0050.00515.32
7.0.40.0130.00315.32
7.0.30.0040.01115.32
7.0.20.0060.00315.32
7.0.10.0040.01215.32
7.0.00.0000.01815.32
5.6.400.0090.00915.32
5.6.390.0030.01415.32
5.6.380.0040.01014.92
5.6.370.0040.01115.32
5.6.360.0090.00615.32
5.6.350.0080.00815.32
5.6.340.0040.00715.32
5.6.330.0030.01315.32
5.6.320.0130.00315.32
5.6.310.0090.00915.32
5.6.300.0070.00715.32
5.6.290.0110.00415.32
5.6.280.0110.00715.32
5.6.270.0060.00915.32
5.6.260.0080.00815.32
5.6.250.0090.00315.32
5.6.240.0030.00915.32
5.6.230.0040.01115.32
5.6.220.0130.00715.32
5.6.210.0100.00715.32
5.6.200.0060.01315.32
5.6.190.0030.01415.32
5.6.180.0060.01115.32
5.6.170.0060.00915.32
5.6.160.0070.01015.32
5.6.150.0070.00715.32
5.6.140.0040.00815.32
5.6.130.0070.01015.32
5.6.120.0070.01015.32
5.6.110.0130.00315.32
5.6.100.0100.00715.32
5.6.90.0030.01415.32
5.6.80.0070.00715.32
5.6.70.0060.01015.32
5.6.60.0070.01115.32
5.6.50.0120.00615.32
5.6.40.0060.00915.32
5.6.30.0060.01215.32
5.6.20.0040.00815.32
5.6.10.0000.01615.32
5.6.00.0040.01115.32

preferences:
58.78 ms | 403 KiB | 5 Q