I get a phone number, where I would like to replace
0049
049
49
with a null.
I can do it like this:
$phone = str_replace("0049", "0", $phone);
// and so on
But for the case that a "049" is in the middle of the phone number:
00491384004924
Fail!! :/
How can I do it better?
2
Answers
does the phone got fixed length (like mobile number) ?
if so , then check length of phone number and remove first symbols based on the lenght.
something like this
and result is
Use preg_replace() with a start-of-string anchor
Demo ~ https://3v4l.org/YRkeB