Hi, I need a regex to strip out all non alphanumeric characters from a string but I'm rubbish at them. I have written the following function but I'm sure that there must be a way of doing it with preg that would be a lot quicker.
<?
function makeAlNum($word)
{
$newword="";
for($i=0;$i<strlen($word);$i++) {
if(preg_match("/[a-zA-Z0-9]/",substr($word,$i,1))) {
$newword.=substr($word,$i,1);
}
}
return $newword;
}
?>
Thanks in advance
Rob