preg replace - preg_replace whitespace also breaks my special characters -
i have string contains lot of whitespaces , line breaks clean up, use:
$str = trim(preg_replace('/\s+/', ' ', $str));
however, when echo out $str notice special characters " à " turn �.
when remove preg_replace � becomes " à " again, string full of whitespaces , linebreaks.
i tried google (ofc) not whole lot of people seem experience problem :)
my knowledge of php intermediate, (still) kinda lack insight of problem might occur :)
maybe there problem charset
$text = utf8_decode($text); $text = trim(preg_replace('/\s+/', ' ', $text)); $text = utf8_encode($text);
are getting utf-8 input?
Comments
Post a Comment