- var_dump: documentation ( source)
- preg_match: documentation ( source)
- array_filter: documentation ( source)
<?php
function checkPhysicalAddressOnFile($addresses) {
return (bool) count(array_filter($addresses, function($address) {
return !preg_match("/p\.o\. box|p\.o box|po box|po\. box|pobox|post office box/i", $address);
}));
}
echo "First test:\n";
var_dump(checkPhysicalAddressOnFile([
"P.O. box 123",
"123 Main St"
]));
echo "\nSecond test:\n";
var_dump(checkPhysicalAddressOnFile([
"P.O. box 123",
"Post Office Box 999"
]));