3v4l.org

run code in 500+ PHP versions simultaneously
<?php $zip_codes = array( '12556', '765547', '234*', '987*', '237' ); $target_zip = '2347890'; foreach($zip_codes as $zip ) { $digitsOnly = preg_replace("~^(\d+)\**$~", "$1", $zip); if (strpos($target_zip, $digitsOnly) === 0) { echo "$zip matched $target_zip" . PHP_EOL; break; } else { echo "$zip not matched $target_zip" . PHP_EOL; } }
Output for 7.2.0 - 7.2.33, 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.31, 8.4.1 - 8.4.22, 8.5.0 - 8.5.7
12556 not matched 2347890 765547 not matched 2347890 234* matched 2347890

preferences:
98.1 ms | 1515 KiB | 4 Q