String with only characters and numbers


Use the preg_replace php function to parse your string.

String literal numbers regular expression

if you have a string but you don't know its content you can be sure obtaining an only numbers and characters string with the following code:

$string = preg_replace("/[^ \w]+/", "", $string);

Related articles