How do I validate phone numbers using regex in php? -


this question has answer here:

i'm coding in php , happy if me regex validate phone numbers in format +233 245 245 245 or 0245 245 245.

i want phone number validated whether or not spaces included. lot in advance.

something simple work:

$string = "(232) 555-5555"; $expr = '/^\+?(\(?[0-9]{3}\)?|[0-9]{3})[-\.\s]?[0-9]{3}[-\.\s]?[0-9]{4}$/'; if (preg_match($expr, $string) == 1) { echo "number validated successfully."; } 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -