PHP Strip Non-Alphanumeric Chars from a String

Published 1st July 2012

Find myself using this fairly often:

$string = preg_replace("/[^a-z0-9]+/i", "", $string);