i have a problem with a function in php i want to convert all the " " in a clear space, i've tried with this, but it doesn't work
function clean($text) {
if ($text === null) return null;
if (strstr($text, "\xa7") || strstr($text, "&")) {
$text = preg_replace("/(?i)(\x{00a7}|&)[0-9A-FK-OR]/u", "", $text);
}
$text = htmlspecialchars($text, ENT_QUOTES, "UTF-8");
if (strstr($text, "
")) {
$text = preg_replace("
", "", $text);
}
return $text;
}
The site: click here
If you literally have " " in your text, which appears to be the case from your screenshots, then do the following:
$text = str_replace("\ ", '', $text);
is a special character in PHP that creates new lines, so we need to add the escape character
\
in front of it in order to remove text instances of " ".
preg_replace()
seems to work better this way:
$text = preg_replace('/
/',"",$text);
Single quotes enforce no substitution when sending your pattern to the parser.