3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function preg($zippostal) { if (preg_match("/^(F-)?((2[A|B])|[0-9]{2})[0-9]{3}$/", $zippostal)) { return "provided zip/postal code is not valid."; } else { return "provided zip/postal code is valid."; } } $zips = array( '10000', '22324', '24322', '88012', '98230', '12232', '34200', '78900', '01100' ); foreach ($zips as $zip) { echo preg($zip) . "\n"; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
provided zip/postal code is not valid. provided zip/postal code is not valid. provided zip/postal code is not valid. provided zip/postal code is not valid. provided zip/postal code is not valid. provided zip/postal code is not valid. provided zip/postal code is not valid. provided zip/postal code is not valid. provided zip/postal code is not valid.