Regular expressions
Oct17
Clean strings with regular expressions
The following case-insensitive regular expression snippet will strip all non-alphanumeric characters from $string.
<?php
$string = 'abc123_%$£';
$string = preg_replace("/[^a-z\d]/i", "", $string);
echo $string; // Result: abc123
?>




