- preg_match: documentation ( source)
- trim: documentation ( source)
- strtolower: documentation ( source)
<?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 ;