1. with preg_replace(); function
preg_replace('#\W#', '' $string);
Eg:
$string = "php__ n?othing b ut le;tte,rs and n!um.bers";
$stripped_string = preg_replace('#\W#', '' $string);
echo $stripped_string;
$stripped_string = preg_replace('#\W#', '' $string);
echo $stripped_string;
should output;
phpnothingbutlettersandnumbers
2. with ereg_replace(); function
ereg_replace("[^A-Za-z0-9]", "", $string );
Eg:
$string = "php__ n?othing b ut le;tte,rs and n!um.bers";
$stripped_string = ereg_replace("[^A-Za-z0-9]", "", $string );
echo $stripped_string;
$stripped_string = ereg_replace("[^A-Za-z0-9]", "", $string );
echo $stripped_string;
should output;
phpnothingbutlettersandnumbers
