I have an array that contains phone numbers in different format:
$myArr[0][0] == '122-33-2222';
$myArr[1][0] == '(122) 433-5555';
$myArr[2][0] == '122 644.8888';
I need to check if another number is in that array. I assume I need to loop through array and strip all non-numeric values before I compare.
$findNumber = 122.433.5555;
$varPhone = preg_replace("/[^0-9,.]/", "", $findNumber);
foreach ($myArr AS $phone) {
if (preg_replace("/[^0-9,.]/", "", $phone) == $varPhone) {
echo "found";
} else {
echo "not found";
}
}
I think I'm close but it's not quite there. What am I missing?