3v4l.org

run code in 500+ PHP versions simultaneously
<?php $strings = [ "123456-12345", "12345678901", "12345678", "1312345678912", "12345678901", "1234567890123", "12345-12345", "1234567-12345", "123456", "12345678901234", "1234567890", "123456789088", "123456789-12345", "1111111111111111111" ]; $pattern = "/^(?:\d{6}-\d+|\d{8}|\d{11}|\d{13})$/"; foreach ($strings as $str) { if (preg_match($pattern, $str)) { echo "Match --> $str"; } else { echo "No match --> $str"; } echo PHP_EOL; }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.4, 8.3.6 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.7
Match --> 123456-12345 Match --> 12345678901 Match --> 12345678 Match --> 1312345678912 Match --> 12345678901 Match --> 1234567890123 No match --> 12345-12345 No match --> 1234567-12345 No match --> 123456 No match --> 12345678901234 No match --> 1234567890 No match --> 123456789088 No match --> 123456789-12345 No match --> 1111111111111111111
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Match --> 123456-12345 Match --> 12345678901 Match --> 12345678 Match --> 1312345678912 Match --> 12345678901 Match --> 1234567890123 No match --> 12345-12345 No match --> 1234567-12345 No match --> 123456 No match --> 12345678901234 No match --> 1234567890 No match --> 123456789088 No match --> 123456789-12345 No match --> 1111111111111111111

preferences:
104.31 ms | 1464 KiB | 4 Q