3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $poxBox = array(); $poxBox[] = 'POBOX'; $poxBox[] = 'P.O\.'; $poxBox[] = 'P.O'; $poxBox[] = 'PO\.'; $poxBox[] = 'APO.'; $poxBox[] = 'A.P.O\.'; $poxBox[] = 'A.P.O'; $poxBox[] = 'GPO\.'; $poxBox[] = 'G.P.O\.'; $poxBox[] = 'G.P.O'; $poxBox[] = 'N.O\.'; $poxBox[] = 'N.O'; $poxBox[] = 'P.O.Box'; $poxBox[] = 'P.OBox'; $poxBox[] = 'PO.Box'; $poxBox[] = 'PO Box'; $poxBox[] = 'APO'; $poxBox[] = 'FPO'; $poxBox[] = 'PO'; $street1='po'; $isMatch = false; for($i =0 ; $i<count($poxBox); $i++){ $pattern = strtolower(trim($poxBox[$i])); $pos = preg_match('/\b'.$pattern.'\b/', $street1,$match); if ($pos) { // if ( preg_match('/'.$pattern.'/', $street1)){ $isMatch = 1; break; }else{ $isMatch = 2; } } echo $isMatch ;
based on 8HjY8
Output for 4.3.0 - 7.3.0rc4
1