Re: [PHP] strip_tags and nl2br
- From: dmagick@xxxxxxxxx (Chris)
- Date: Wed, 21 May 2008 17:34:42 +1000
James Colannino wrote:
Chris wrote:
RTM.
Supply the tags you want to keep when you call strip_tags.
$stripped = strip_tags($data, '<br/><br>');
I can do that, but my question had to do with strip_tags seeming to get
rid of \n's, not <br> tags. This is why I was concerned. If I run
strip_tags(), followed by nl2br, the <br> tags that nl2br generates
should be there.
Are you sure there are newlines before you run strip_tags? It doesn't
touch newlines because they aren't html entities.
$ cat eg.php
<?php
$string = "<b>here is a bold tag</b>\n<a
href='http://www.example.com/'>Link to example.com</a>\n\n";
echo "Strip tags only:\n";
echo strip_tags($string) . "\n";
echo str_repeat('-', 10) . "\n";
echo "Strip tags & nl2br:\n";
echo nl2br(strip_tags($string)) . "\n";
?>
$ php eg.php
Strip tags only:
here is a bold tag
Link to example.com
----------
Strip tags & nl2br:
here is a bold tag<br />
Link to example.com<br />
<br />
--
Postgresql & php tutorials
http://www.designmagick.com/
.
- Follow-Ups:
- Re: [PHP] strip_tags and nl2br
- From: James Colannino
- Re: [PHP] strip_tags and nl2br
- References:
- strip_tags and nl2br
- From: James Colannino
- Re: [PHP] strip_tags and nl2br
- From: Chris
- Re: [PHP] strip_tags and nl2br
- From: James Colannino
- strip_tags and nl2br
- Prev by Date: Re: [PHP] strip_tags and nl2br
- Next by Date: Re: Odd error
- Previous by thread: Re: [PHP] strip_tags and nl2br
- Next by thread: Re: [PHP] strip_tags and nl2br
- Index(es):
Relevant Pages
|