3v4l.org

run code in 300+ PHP versions simultaneously
<?php $haystack = "I like cats."; $needles = ['cat' => 0, 'dog' => 1]; function regex(string $haystack, array $needles) { $regex = implode('|', array_map('preg_quote', array_keys($needles))); if (!preg_match("#$regex#", $haystack, $m)) { throw new Exception('No needles were found in the haystack'); } return $needles[$m[0]]; } try { var_export(regex($haystack, $needles)); } catch (Exception $e) { echo $e->getMessage(); }

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.5.10.0150.00517.06
8.5.00.0150.00820.22
8.4.150.0010.00114.05
8.4.140.0130.00817.89
8.4.130.0150.00618.79
8.4.120.0040.00522.40
8.4.110.0100.00818.82
8.4.100.0100.01118.02
8.4.90.0120.00820.58
8.4.80.0090.01018.75
8.4.70.0080.01018.89
8.4.60.0110.00918.97
8.4.50.0100.01020.43
8.4.40.0110.00717.84
8.4.30.0030.01618.84
8.4.20.0100.01019.75
8.4.10.0060.00319.74
8.3.280.0110.00818.52
8.3.270.0120.00816.82
8.3.260.0150.00516.69
8.3.250.0120.00717.19
8.3.240.0090.00716.82
8.3.230.0120.00716.74
8.3.220.0100.00919.00
8.3.210.0100.00618.80
8.3.200.0050.00416.61
8.3.190.0100.00916.81
8.3.180.0110.00416.73
8.3.170.0110.01118.66
8.3.160.0130.00617.20
8.3.150.0000.00818.93
8.3.140.0090.00018.72
8.3.130.0040.00416.71
8.3.120.0030.00620.66
8.3.110.0080.01220.94
8.3.100.0000.01116.71
8.3.90.0110.00416.54
8.3.80.0070.00318.31
8.3.70.0040.01118.30
8.3.60.0060.01316.94
8.3.50.0110.00718.39
8.3.40.0070.00723.65
8.3.30.0130.01022.96
8.3.20.0120.00922.96
8.3.10.0130.00722.96
8.3.00.0160.00622.96
8.2.290.0070.00716.73
8.2.280.0090.01120.31
8.2.270.0100.01019.27
8.2.260.0000.00818.76
8.2.250.0040.00418.63
8.2.240.0030.00618.88
8.2.230.0100.00022.58
8.2.220.0070.00324.06
8.2.210.0110.00326.77
8.2.200.0040.00416.75
8.2.190.0100.01016.63
8.2.180.0110.00716.50
8.2.170.0070.00722.96
8.2.160.0110.01122.96
8.2.150.0150.00622.96
8.2.140.0100.01022.96
8.2.130.0100.01022.96
8.2.120.0130.00722.96
8.2.110.0040.01522.96
8.2.100.0070.01122.96
8.2.90.0120.00922.96
8.2.80.0100.01022.96
8.2.70.0110.00722.96
8.2.60.0090.00922.96
8.2.50.0070.01122.96
8.2.40.0120.00922.96
8.2.30.0130.00922.96
8.2.20.0130.00722.96
8.2.10.0150.00722.96
8.2.00.0090.00922.96
8.1.330.0100.00816.52
8.1.320.0120.00816.55
8.1.310.0040.01418.29
8.1.300.0040.00418.57
8.1.290.0080.00418.88
8.1.280.0110.00725.92
8.1.270.0180.00022.96
8.1.260.0140.00722.96
8.1.250.0140.00422.96
8.1.240.0070.01422.96
8.1.230.0060.01222.96
8.1.220.0100.01022.96
8.1.210.0110.01122.96
8.1.200.0030.01722.96
8.1.190.0140.00422.96
8.1.180.0120.00622.96
8.1.170.0110.00722.96
8.1.160.0040.01422.96
8.1.150.0210.00022.96
8.1.140.0130.00722.96
8.1.130.0180.00022.96
8.1.120.0090.00922.96
8.1.110.0140.00422.96
8.1.100.0100.01022.96
8.1.90.0040.01922.96
8.1.80.0150.00622.96
8.1.70.0160.00022.96
8.1.60.0040.01122.96
8.1.50.0120.00322.96
8.1.40.0110.00322.96
8.1.30.0040.01222.96
8.1.20.0000.01522.96
8.1.10.0120.00322.96
8.1.00.0070.00722.96

preferences:
96.76 ms | 403 KiB | 5 Q