This question has already been answered:

Good afternoon, I want to remove the extra characters from the phone number (099) 656-66-33 , such as - , ( , ) and a space to get the result 0996566633

Help create the right filter mask.

Reported as a duplicate by members of Visman , tutankhamun , Mike , Alexey Shimansky , pavel 17 Oct '16 at 11:59 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • But what is the difficulty then \D+ takes all NOT numbers - Mike

1 answer 1

 $input = '(099) 656-66-33'; $result = preg_replace('/[^\d]+/', '', $input);