I have "string" from form in phone format it can be (111) 324-3443 or others. How to remove from the string all characters except digits. So I need 1113243443.
TH
$only_numbers = preg_replace('%[^\\d]%', '', $input);
or, saving a few keystrokes, \D instead of [\d]
What the purpose of %?
just the separator that tells the regex machine where the pattern starts and ends. you can use slashes instead which is more commom, but by no ways required.