Delete specific word from a string

1

Good evening, everyone. I'm having an issue that is as follows:

I need to remove the ' <br> ' tag at the end of the data in my database (PostgreSQL), due to the text editor it automatically places.

I could not create anything capable of doing this, but I imagine that if I check the presence of this tag and delete it before the display it would work (talking is easier than doing, is not it?)

Anyway, thank you in advance!

    
asked by anonymous 05.11.2015 / 01:35

2 answers

3

You can also choose to use this regular expression, which causes '
' to be inserted by html,

$string = "Texto com linha <br> e linha 2";
$string = str_replace("<br>", "", $string); 

In MYSQL you can do the following:

UPDATE tabela SET campo = REPLACE(campo, '<br>', '');
    
05.11.2015 / 02:08
2

If I get it right, you can solve this by using a regular expression to get the '< br >' unnecessary string.

$texto = "linha 1<br>linha 2<br>";
$texto = preg_replace('(<br>$)', '', $texto);
//remove apenas o <br> do final, mantém os anteriores
    
05.11.2015 / 01:47