<?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; } }
You have javascript disabled. You will not be able to edit any code.