I am currently doing this:
$a = 'some string with special characters';
$a = htmlentities($a);
$a = trim(preg_replace('/&#?[a-z0-9]+;/i', '', $a));
This works but I am wondering if there's a more efficient way to do this?
I am currently doing this:
$a = 'some string with special characters';
$a = htmlentities($a);
$a = trim(preg_replace('/&#?[a-z0-9]+;/i', '', $a));
This works but I am wondering if there's a more efficient way to do this?
it contains certain characters like  and I want to remove those.
Try utf8_decode
, or more feature-filled:
$output = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $input);
The reason I bring this up is because what you are seeing are encoding issues, not "special characters".