html - PHP Cleaning special characters from string -
so made scrapper , returns strings multiple sites. want check if strings match, use php clean string , check. however, &
, other special characters appear in 2 ways, 1 &
, other &
. how go removing each type.
preg_replace("/[^a-za-z0-9]+/", "", $string);
i have that, doesn't take out special characters.
thanks.
try
function removespecialchar($string) { $string = str_replace('', '-', $string); // replaces spaces hyphens. return preg_replace('/[^a-za-z0-9\-]/', '', $string); // removes special chars. } echo removespecialchar(html_entity_decode('&khawer&')); //will output khawer
Comments
Post a Comment