PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
lauthiamkok
Forum Contributor
Posts: 153 Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom
Post
by lauthiamkok » Sat Sep 25, 2010 8:28 am
Hi,
How it is possible to allow
in strip_tags() or any way I can get around to it?
Code: Select all
<?php
$text = '<p>Test <br />paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
echo "\n";
// Allow <p>, <a>, <br />
echo strip_tags($text, '<p><a><br />');
echo "\n";
// Allow <br /> only
echo strip_tags($text, '<br />');
?>
result:
Test paragraph. Other text
<p>Test paragraph.</p> <a href="#fragment">Other text</a>
Test paragraph. Other text
Thanks,
Lau
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sat Sep 25, 2010 8:29 am
Question: you use <p> and not <p />, <a> and not <a />, so why a <br / >?
lauthiamkok
Forum Contributor
Posts: 153 Joined: Wed Apr 01, 2009 2:23 pm
Location: Plymouth, United Kingdom
Post
by lauthiamkok » Sat Sep 25, 2010 8:34 am
tasairis wrote: Question: you use <p> and not <p />, <a> and not <a />, so why a <br / >?
thanks for the thought. got the answer now
thanks!
Eran
DevNet Master
Posts: 3549 Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME
Post
by Eran » Sat Sep 25, 2010 8:57 am
tasairis wrote: Question: you use <p> and not <p />, <a> and not <a />, so why a <br / >?
This is the XHTML syntax for self closing tags
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sat Sep 25, 2010 8:35 pm
pytrin wrote: tasairis wrote: Question: you use <p> and not <p />, <a> and not <a />, so why a <br / >?
This is the XHTML syntax for self closing tags
...Yeah, I know. It was a rhetorical question to get OP to think for a second...
Eran
DevNet Master
Posts: 3549 Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME
Post
by Eran » Sat Sep 25, 2010 8:59 pm
oh, sorry, missed that one
Didn't go through his entire code