3v4l.org

run code in 300+ PHP versions simultaneously
<?php function str_intersection($str1, $str2) { [$long, $short] = strlen($str1) > strlen($str2) ? [$str1, $str2] : [$str2, $str1]; $shortLength = strlen($short); for ($length = $shortLength; $length > 0; $length--) { for ($offset = 0; $offset < $shortLength - 1; $offset++) { if (strpos($long, substr($short, $offset, $length)) !== false) return $length; } } return 0; } $str1 = "lorem ipsum"; $str2 = "rem"; echo str_intersection($str1, $str2) . PHP_EOL; // Expected result: 3 $str2 = "xzy"; echo str_intersection($str1, $str2) . PHP_EOL; // Expected result: 0

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.0140.00016.58
8.3.60.0140.00716.48
8.3.50.0180.00018.18
8.3.40.0130.00719.92
8.3.30.0100.01018.39
8.3.20.0000.00824.18
8.3.10.0080.00024.66
8.3.00.0040.00426.16
8.2.190.0080.00816.88
8.2.180.0110.00425.92
8.2.170.0040.01122.96
8.2.160.0080.00822.96
8.2.150.0070.00025.66
8.2.140.0060.00324.66
8.2.130.0050.00226.16
8.2.120.0040.00419.44
8.2.110.0040.00820.50
8.2.100.0060.00620.34
8.1.280.0100.00725.92
8.1.270.0050.00318.70
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0040.00418.62
8.1.230.0060.00318.70
8.0.250.0070.00319.07

preferences:
18.53 ms | 401 KiB | 5 Q