<?php $zip_codes = array( '12556', '765547', '234*', '987*' ); $target_zip = '2347890'; foreach( $zip_codes as $zip ) { echo $zip; if (preg_match('/' . str_replace('*', '.*', $zip) . '/', $target_zip)) { echo ' matched'. PHP_EOL; break; } else { echo ' not matched' . PHP_EOL; } }
You have javascript disabled. You will not be able to edit any code.