3v4l.org

run code in 300+ PHP versions simultaneously
<?php $haystack = "I like cats."; $needles = ['cat' => 0, 'dog' => 1]; function earlyReturn(string $haystack, array $needles) { foreach ($needles as $needle => $value) { if (strpos($haystack, $needle) !== false) { return $value; } } throw new Exception('No needles were found in the haystack'); } try { var_export(earlyReturn($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.3.70.0060.00918.31
8.3.60.0100.01016.52
8.3.50.0030.01218.52
8.3.40.0150.00423.65
8.3.30.0120.00622.96
8.3.20.0110.00722.96
8.3.10.0120.00522.96
8.3.00.0090.00922.96
8.2.190.0040.01116.63
8.2.180.0170.00018.54
8.2.170.0060.00922.96
8.2.160.0090.00922.96
8.2.150.0110.00622.96
8.2.140.0120.00522.96
8.2.130.0090.00922.96
8.2.120.0090.00722.96
8.2.110.0080.01022.96
8.2.100.0090.01222.96
8.2.90.0110.00822.96
8.2.80.0050.01322.96
8.2.70.0090.00822.96
8.2.60.0130.00522.96
8.2.50.0140.00422.96
8.2.40.0050.01322.96
8.2.30.0110.00722.96
8.2.20.0050.01122.96
8.2.10.0110.00822.96
8.2.00.0110.00622.96
8.1.280.0070.00725.92
8.1.270.0090.00522.96
8.1.260.0110.00522.96
8.1.250.0050.01122.96
8.1.240.0080.00922.96
8.1.230.0090.00622.96
8.1.220.0060.00822.96
8.1.210.0060.00822.96
8.1.200.0090.00522.96
8.1.190.0100.00322.96
8.1.180.0110.00822.96
8.1.170.0070.01122.96
8.1.160.0070.01222.96
8.1.150.0110.00922.96
8.1.140.0070.00922.96
8.1.130.0070.00922.96
8.1.120.0090.01022.96
8.1.110.0090.00922.96
8.1.100.0120.00622.96
8.1.90.0090.00922.96
8.1.80.0080.00722.96
8.1.70.0050.01022.96
8.1.60.0130.00322.96
8.1.50.0050.01222.96
8.1.40.0100.00622.96
8.1.30.0130.00522.96
8.1.20.0060.00922.96
8.1.10.0030.01222.96
8.1.00.0080.00722.96

preferences:
23.14 ms | 401 KiB | 5 Q