3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Thesaurus { protected $synonyms = array( array('wonderful', 'great', 'amazing', 'fabulous', 'awesome', 'stunning'), array('look', 'see', 'observe') ); public function lookup($word) { foreach ($this->synonyms as $index => $synonym) { if (in_array(strtolower($word), $synonym)) { unset($synonym[$word]); return $synonym[ array_rand($synonym) ]; } } return $word; } } class Transformer { protected $thesaurus; public function __construct(Thesaurus $thesaurus) { $this->thesaurus = $thesaurus; } public function transform($string) { foreach (str_word_count($string, 1) as $word) { $string = $this->replace($word, $this->thesaurus->lookup($word), $string); } return $string; } private function replace($needle, $replacement, $haystack) { return preg_replace( '~' . preg_quote($needle, '~') . '~i', $replacement, $haystack, 1 ); } } $transformer = new Transformer(new Thesaurus); foreach (range(1, 20) as $index) { echo $transformer->transform('This is my great description. It really is wonderful. Look how wonderful it is.'), 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.2.00.0050.00919.62
7.1.70.0000.01217.51
7.1.60.0110.01119.70
7.1.50.0030.02117.19
7.1.00.0130.06322.36
7.0.200.0980.00014.97
7.0.140.0000.07722.21
7.0.90.0000.08019.98
7.0.80.0100.06719.95
7.0.70.0370.07719.95
7.0.60.0100.04320.07
7.0.50.0130.04320.39
7.0.40.0030.05020.15
7.0.30.0130.03320.00
7.0.20.0000.04720.05
7.0.10.0100.04320.07
7.0.00.0070.08320.09
5.6.280.0100.07021.04
5.6.230.0100.05720.61
5.6.220.0070.07720.75
5.6.210.0100.05720.59
5.6.200.0000.04721.02
5.6.190.0100.04321.09
5.6.180.0030.03721.07
5.6.170.0030.04320.95
5.6.160.0130.06321.06
5.6.150.0000.04321.12
5.6.140.0000.05021.05
5.6.130.0000.04721.07
5.6.120.0030.06321.15
5.6.110.0000.05020.98
5.6.100.0030.04321.14
5.6.90.0070.08320.93
5.6.80.0000.04320.47
5.6.70.0100.03320.32
5.6.60.0100.07320.39
5.6.50.0130.08020.40
5.6.40.0130.04320.44
5.6.30.0130.05320.38
5.6.20.0070.08320.41
5.6.10.0030.07720.39
5.6.00.0070.05320.52
5.5.370.0070.08720.46
5.5.360.0030.06320.46
5.5.350.0070.05020.46
5.5.340.0030.04320.84
5.5.330.0070.04020.79
5.5.320.0100.06320.75
5.5.310.0030.04720.86
5.5.300.0000.04020.82
5.5.290.0000.07320.89
5.5.280.0030.04320.73
5.5.270.0000.05020.93
5.5.260.0000.04720.83
5.5.250.0000.04720.75
5.5.240.0130.06020.23
5.5.230.0070.07720.27
5.5.220.0100.08020.27
5.5.210.0030.05720.17
5.5.200.0000.07720.26
5.5.190.0130.07320.27
5.5.180.0100.07720.22
5.5.160.0070.08020.23
5.5.150.0100.08020.00
5.5.140.0100.06720.14
5.5.130.0070.07320.19
5.5.120.0030.07320.23
5.5.110.0100.04720.19
5.5.100.0130.07320.10
5.5.90.0130.07319.96
5.5.80.0100.07720.17
5.5.70.0030.06020.15
5.5.60.0070.07720.09
5.5.50.0130.07320.18
5.5.40.0130.07020.09
5.5.30.0100.07320.09
5.5.20.0000.08320.04
5.5.10.0130.07319.95
5.5.00.0130.05320.14
5.4.450.0030.04319.18
5.4.440.0070.03719.37
5.4.430.0030.05019.36
5.4.420.0030.04719.46
5.4.410.0030.04019.24
5.4.400.0000.05718.88
5.4.390.0100.07319.03
5.4.380.0130.07318.85
5.4.370.0070.06719.14
5.4.360.0100.07718.95
5.4.350.0130.03019.03
5.4.340.0000.08019.09
5.4.320.0100.07319.16
5.4.310.0200.06719.18
5.4.300.0130.04719.03
5.4.290.0130.06019.12
5.4.280.0100.05319.21
5.4.270.0200.07019.09
5.4.260.0030.08019.16
5.4.250.0070.05019.00
5.4.240.0130.07019.08
5.4.230.0130.06719.11
5.4.220.0100.07019.15
5.4.210.0170.06019.12
5.4.200.0070.08019.11
5.4.190.0100.06018.84
5.4.180.0100.07319.02
5.4.170.0030.08319.04
5.4.160.0070.06719.14
5.4.150.0100.08018.92
5.4.140.0070.07016.45
5.4.130.0070.07716.37
5.4.120.0170.06716.48
5.4.110.0100.07316.50
5.4.100.0070.07016.49
5.4.90.0100.07016.52
5.4.80.0170.06316.51
5.4.70.0270.03016.36
5.4.60.0200.06016.54
5.4.50.0000.06316.47
5.4.40.0130.06716.49
5.4.30.0130.06316.41
5.4.20.0070.08016.44
5.4.10.0100.06016.34
5.4.00.0030.07015.94
5.3.290.0030.08714.62
5.3.280.0130.07014.56
5.3.270.0130.07314.68
5.3.260.0130.07314.66
5.3.250.0070.08014.61
5.3.240.0070.07314.63
5.3.230.0070.08714.72
5.3.220.0070.08014.61
5.3.210.0300.06014.57
5.3.200.0030.07314.52
5.3.190.0070.05314.64
5.3.180.0030.08014.50
5.3.170.0070.07314.59
5.3.160.0070.07014.59
5.3.150.0070.07314.71
5.3.140.0200.07714.50
5.3.130.0030.08314.66
5.3.120.0070.06314.57
5.3.110.0070.07314.66
5.3.100.0170.07013.98
5.3.90.0070.07713.96
5.3.80.0170.06013.97
5.3.70.0000.04714.15
5.3.60.0170.02713.92
5.3.50.0000.06714.10
5.3.40.0100.07313.95
5.3.30.0070.07314.06
5.3.20.0100.05313.80
5.3.10.0030.07713.80
5.3.00.0030.07313.80
5.2.170.0030.06713.80
5.2.160.0100.05713.80
5.2.150.0030.06313.80
5.2.140.0130.05313.80
5.2.130.0030.06313.80
5.2.120.0100.06013.80
5.2.110.0070.04713.80
5.2.100.0000.05713.80
5.2.90.0100.05713.80
5.2.80.0100.06013.80
5.2.70.0030.06313.80
5.2.60.0030.04013.80
5.2.50.0100.06013.80
5.2.40.0070.05713.80
5.2.30.0070.04313.80
5.2.20.0030.05313.80
5.2.10.0070.04713.80
5.2.00.0030.04713.80
5.1.60.0000.05713.80
5.1.50.0030.06313.80
5.1.40.0130.04713.80
5.1.30.0130.05313.80
5.1.20.0070.05713.80
5.1.10.0070.04713.80
5.1.00.0030.05713.80
5.0.50.0030.05713.80
5.0.40.0030.04713.80
5.0.30.0030.06713.80
5.0.20.0030.02313.80
5.0.10.0030.03013.80
5.0.00.0000.07013.80
4.4.90.0000.02713.80
4.4.80.0070.03013.80
4.4.70.0000.03713.80
4.4.60.0100.03013.80
4.4.50.0000.03713.80
4.4.40.0070.05713.80
4.4.30.0000.02713.80
4.4.20.0070.03313.80
4.4.10.0000.03713.80
4.4.00.0070.02313.80
4.3.110.0070.03313.80
4.3.100.0030.03313.80
4.3.90.0000.02013.80
4.3.80.0030.05713.80
4.3.70.0030.03713.80
4.3.60.0030.01713.80
4.3.50.0000.04013.80
4.3.40.0070.04713.80
4.3.30.0070.03013.80
4.3.20.0000.03713.80
4.3.10.0000.02313.80
4.3.00.0000.03713.80

preferences:
32.65 ms | 400 KiB | 5 Q