'how to check if a string of a number has 10 characters in php
I am struggeling at implementing a check on a textbox.
I want to check if the phone number has a length of 10 characters, contains my country base number and if it is actually a numerical value.
i only know how to check if it is a number.
if(ctype_digit($telefon) && ctype_digit($telefon)=="10"){
...
} else {
echo "Invalid phone number";
}
Solution 1:[1]
Using PHP's 'strlen($string)' function would count every character including any format notations
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MisterG13 |