Hi i have a problem with preg_match function.
i want to check whole text against pattern and return true if whole text matched with pattern and false for not matched or partially matched with pattern but i can't do this with php preg_match function.
for example i use bellow func to check if input is digit or no.
if(preg_match("/[\d]/","99ab") return true; else return false;
above code return true but i want to this return false. and other regex that i want to check is users first name and last name with preg_match.
and another regex for phone numbers with this format (000) 000-0000.
please help me to solve this problem.
Just change the pattern like this:
"/^[\d]+$/"
Remember that:
You need to use ^ to indicate the start of the string and $ for the end
if (preg_match("/^[\d]+$/","99ab")) return true;
else return false;