3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Thesaurus { protected $synonyms = array( array('wonderful', 'great', 'amazing', 'fabulous'), array('look', 'see', 'observe') ); public function replace($word) { foreach ($this->synonyms as $synonym) { if (in_array($word, $synonym)) { 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 = str_replace($word, $this->thesaurus->replace($word), $string); } return $string; } } $transformer = new Transformer(new Thesaurus); echo $transformer->transform('This is my wonderful 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.3.10.0130.00516.66
7.3.00.0110.01116.54
7.2.130.0150.00316.61
7.2.120.0130.00316.86
7.2.110.0100.00316.55
7.2.100.0000.01216.96
7.2.90.0040.01116.95
7.2.80.0080.00416.97
7.2.70.0100.00616.89
7.2.60.0030.00616.95
7.2.50.0080.00017.11
7.2.40.0060.00616.58
7.2.30.0060.00316.63
7.2.20.0070.01116.91
7.2.10.0040.00417.11
7.2.00.0070.00518.13
7.1.250.0000.01215.72
7.1.70.0000.01217.09
7.1.60.0030.02119.40
7.1.50.0040.00816.64
7.1.00.0030.05722.41
7.0.200.0040.00416.64
7.0.140.0030.07322.08
7.0.120.0030.03022.18
7.0.60.0300.06320.05
7.0.50.0000.06717.88
7.0.40.0100.08320.13
7.0.30.0100.08320.18
7.0.20.0070.08320.15
7.0.10.0000.08020.11
7.0.00.0100.04020.23
5.6.280.0070.07021.07
5.6.210.0030.05720.52
5.6.200.0070.04018.27
5.6.190.0000.05720.77
5.6.180.0030.04720.48
5.6.170.0030.04720.61
5.6.160.0170.07320.54
5.6.150.0000.09020.32
5.6.140.0030.05320.52
5.6.130.0230.06320.39
5.6.120.0130.07320.22
5.6.110.0100.05720.50
5.6.100.0000.04720.31
5.6.90.0070.08320.38
5.6.80.0070.08719.56
5.6.70.0100.07719.71
5.6.60.0130.07319.55
5.6.50.0100.04319.55
5.6.40.0100.08019.55
5.6.30.0030.09019.70
5.6.20.0100.06719.85
5.6.10.0130.03319.54
5.6.00.0000.06019.89
5.5.350.0030.08720.43
5.5.340.0100.08017.98
5.5.330.0170.05720.29
5.5.320.0030.08320.47
5.5.310.0030.04320.30
5.5.300.0030.05320.32
5.5.290.0070.06019.99
5.5.280.0070.04720.17
5.5.270.0070.06320.13
5.5.260.0100.08020.18
5.5.250.0130.07319.80
5.5.240.0030.06019.36
5.5.230.0070.07319.34
5.5.220.0070.04019.61
5.5.210.0070.08019.55
5.5.200.0100.07019.39
5.5.190.0070.05319.36
5.5.180.0100.08019.60
5.5.160.0170.03019.33
5.5.150.0130.06319.56
5.5.140.0130.03319.67
5.5.130.0100.07319.66
5.5.120.0130.03719.58
5.5.110.0070.07719.50
5.5.100.0030.07319.46
5.5.90.0030.08719.23
5.5.80.0100.06019.54
5.5.70.0070.06319.25
5.5.60.0070.05319.37
5.5.50.0030.08319.34
5.5.40.0030.04719.43
5.5.30.0070.04319.48
5.5.20.0070.04019.32
5.5.10.0030.04719.37
5.5.00.0070.08719.47
5.4.450.0070.07019.59
5.4.440.0030.05719.56
5.4.430.0130.06719.47
5.4.420.0070.05319.46
5.4.410.0030.06719.43
5.4.400.0130.04018.86
5.4.390.0070.06319.01
5.4.380.0030.05319.12
5.4.370.0030.07719.01
5.4.360.0130.03319.20
5.4.350.0130.04318.98
5.4.340.0100.07719.12
5.4.320.0030.05719.14
5.4.310.0000.07319.15
5.4.300.0070.07718.85
5.4.290.0100.06719.07
5.4.280.0170.07019.24
5.4.270.0030.05018.87
5.4.260.0030.04319.23
5.4.250.0030.07719.14
5.4.240.0000.04019.20
5.4.230.0100.07319.09
5.4.220.0030.06318.85
5.4.210.0070.04019.20
5.4.200.0030.04019.07
5.4.190.0070.04019.23
5.4.180.0000.04019.23
5.4.170.0070.07319.23
5.4.160.0030.07719.18
5.4.150.0030.05319.14
5.4.140.0030.04016.52
5.4.130.0030.04316.44
5.4.120.0070.07016.47
5.4.110.0070.05016.51
5.4.100.0070.03316.36
5.4.90.0070.03316.44
5.4.80.0070.07016.31
5.4.70.0000.04716.43
5.4.60.0100.03016.44
5.4.50.0070.07316.45
5.4.40.0000.05016.29
5.4.30.0100.06716.38
5.4.20.0000.07716.46
5.4.10.0100.07016.36
5.4.00.0170.06015.79
5.3.290.0030.08314.57
5.3.280.0070.08014.64
5.3.270.0000.05014.65
5.3.260.0070.07314.63
5.3.250.0030.07714.62
5.3.240.0100.06714.63
5.3.230.0000.06314.64
5.3.220.0030.05314.46
5.3.210.0030.08014.62
5.3.200.0000.05014.61
5.3.190.0070.03314.58
5.3.180.0130.04714.49
5.3.170.0030.08014.58
5.3.160.0000.07014.72
5.3.150.0000.08014.73
5.3.140.0030.05714.64
5.3.130.0070.07314.59
5.3.120.0030.07314.57
5.3.110.0130.06014.59
5.3.100.0070.07314.10
5.3.90.0070.07014.03
5.3.80.0070.07314.18
5.3.70.0100.07014.07
5.3.60.0030.04714.03
5.3.50.0070.07313.96
5.3.40.0070.08014.13
5.3.30.0070.07013.93
5.3.20.0070.04313.71
5.3.10.0030.06713.64
5.3.00.0070.05313.61
5.2.170.0070.04711.32
5.2.160.0070.03711.23
5.2.150.0070.05711.13
5.2.140.0030.04311.11
5.2.130.0030.04011.11
5.2.120.0000.04011.17
5.2.110.0030.04711.12
5.2.100.0030.06311.10
5.2.90.0030.06011.04
5.2.80.0100.06011.26
5.2.70.0070.03711.12
5.2.60.0030.04311.11
5.2.50.0030.04711.07
5.2.40.0100.02711.01
5.2.30.0000.06010.90
5.2.20.0070.05711.11
5.2.10.0070.03310.76
5.2.00.0070.05010.88
5.1.60.0000.03710.02
5.1.50.0030.04310.03
5.1.40.0030.0339.91
5.1.30.0000.06010.32
5.1.20.0130.04310.30
5.1.10.0030.02710.14
5.1.00.0030.07010.24
5.0.50.0030.0408.57
5.0.40.0000.0478.47
5.0.30.0000.0608.25
5.0.20.0000.0378.37
5.0.10.0030.0408.10
5.0.00.0030.0338.13
4.4.90.0000.0377.70
4.4.80.0070.0207.70
4.4.70.0030.0307.70
4.4.60.0000.0237.70
4.4.50.0000.0377.70
4.4.40.0030.0307.70
4.4.30.0000.0177.70
4.4.20.0030.0207.70
4.4.10.0030.0337.70
4.4.00.0030.0237.70
4.3.110.0000.0207.70
4.3.100.0000.0377.70
4.3.90.0070.0307.70
4.3.80.0100.0377.70
4.3.70.0000.0277.70
4.3.60.0000.0377.70
4.3.50.0030.0207.70
4.3.40.0000.0307.70
4.3.30.0100.0307.70
4.3.20.0030.0337.70
4.3.10.0030.0237.70
4.3.00.0000.0377.70

preferences:
33.69 ms | 400 KiB | 5 Q