I'm going crazy for this...I'm trying to remove some text using a database of strings to be removed. This is my function:
function remove($str){
$query = "SELECT * FROM `deltext` ORDER BY `freq` DESC";
$rslt = mysql_query($query) or die("Error: " . mysql_error());
while ($row= mysql_fetch_array($rslt)){
$str=str_replace($row['text'],"",$str);
}
return $str;
}
The text I'm trying to remove is:
">Lavora con noi
>Posizioni Aperte
</p>"
The following works fine:
$str=str_replace(">Lavora con noi
>Posizioni Aperte
</p>","Paperino",$str);
But if I try to use the database, it won't work, someone know why?
Thanks Valerio
you can use REPLACE function, just remove the * from your query and fetch what you need only like
SELECT REPLACE(deltext.text_name, "_", " ") FROM `deltext` ORDER BY `freq` DESC
also your query is not well written, why you are updating $str everytime, i think you should use $str as an array.
also you can try this
str_replace(html_entity_decode('–', ENT_COMPAT, 'UTF-8'), '', $string);