Filter allowed chars via PHP

From snippet wiki
Jump to: navigation, search

To sanitize user input in webforms, i.e. to get rid of all non-number chars in a telephone input field:

$phone = preg_replace("/[^0-9]+/", "", $phone);

Which leaves only numbers intact.

Autoren der Seite / Contributors of the page

» Kai Kretschmann, (google+)