I have an array of phone numbers, and I need a fast way to split this array into valid and invalid phone numbers (according to my definition of valid and invalid), something like:
$phone_numbers = array(
'04165555555',
'02125555555'
);
$valid_phone_number_regex = '/^0?(416|426|412|424|414)(\d{7})$/i';
I could use array_filter to get all of the valid numbers, but I also need the invalid ones (for reporting issues)
in a fast way, the array may hold thousands of numbers!
array_diff()and you have the invalid ones.array_filterapproach is about the best bet witharray_difffor invalids