Take out all html TAGS less the line break

2

My question is simple, I think.

I get via post the description:

    $descricao = strip_tags(mysql_escape_string(trim($_POST['descricao'])));

And when I print on the screen I use:

    nl2br($foto_user_visitado->descricao)

This should print on the screen the description recognizing the "enter" but as I put the strip_tags function it does not show. How can I do it? and I want to escape all tags html.

    
asked by anonymous 22.09.2015 / 01:40

1 answer

1

If the line break is the <br /> tag, just put a second parameter in the strip_tags function and it will indicate which tags should be kept.

For example:

<?php

//somente as tags <br> e <i> serão mantidas
$texto = strip_tags("<b>texto</b> com<br /><i>tags</i><br />html", '<br><i>');

echo $texto;

Will return:

text with
tags
html

    
15.10.2016 / 04:56