I have the following phone number in the database: (45) 9 9874-4700
Is there any function that I just leave NUMBERS? what character is in the middle of the tag?
I have the following phone number in the database: (45) 9 9874-4700
Is there any function that I just leave NUMBERS? what character is in the middle of the tag?
Yes. You can use the preg_replace
function. It will use regular expressions to remove, change certain characters.
Example:
preg_replace("/\D/", "", "(45) 9 9874-4700");
In regular expressions, \D
means: All characters other than 0 to 9.
That is, we select all the characters that are not numbers and in the second parameters we inform by which characters we must change (in this case by none).