I know there is strip_tags() for stripping all the tags

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

Post Reply
User avatar
raymund_revolution
Forum Newbie
Posts: 3
Joined: Tue Aug 25, 2009 9:38 pm

I know there is strip_tags() for stripping all the tags

Post by raymund_revolution »

Hi all,

I know there is strip_tags() for stripping all the tags.
But i want to leave img tags only. How can i strip img tags only?

Here' my code:

$input = "<img height="105" align="left" width="98" alt="" style="margin-right: 8px;" src="/userfiles/image/main%20pages/th_jason.jpg" /><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce ac dui ac nulla laoreet blandit vel eu tellus. </p>";
$images=stripslashes(strip_tags(mysql_result($input),'<img>'));

Any help, must appreciated...thanks.

raymund
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: I know there is strip_tags() for stripping all the tags

Post by requinix »

raymund_revolution wrote:Here' my code:
No, that's not your code. Try posting it again?
User avatar
raymund_revolution
Forum Newbie
Posts: 3
Joined: Tue Aug 25, 2009 9:38 pm

Re: I know there is strip_tags() for stripping all the tags

Post by raymund_revolution »

Ok, Here's an example code:

$input = "<p><img height="105" align="left" width="98" alt="" style="margin-right: 8px;" src="/userfiles/image/main%20pages/century.jpg" />This is my first code</p>"

$content =strip_tags($input'),'<img>');
echo $content;

It display the images and the content, But what i want is to display the images only. How could i do that in strip_tags()?

Any help, must appreciated.

Thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: I know there is strip_tags() for stripping all the tags

Post by requinix »

raymund_revolution wrote:Ok, Here's an example code:

$input = "<p><img height="105" align="left" width="98" alt="" style="margin-right: 8px;" src="/userfiles/image/main%20pages/century.jpg" />This is my first code</p>"

$content =strip_tags($input'),'<img>');
echo $content;

It display the images and the content,
No. No example code. What you gave doesn't even compile.

What is your code?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: I know there is strip_tags() for stripping all the tags

Post by jackpf »

Yeah, your code doesn't work. Like, at all. I can see about 10 parse errors just looking at it.

And read up on strip_tags's second argument.
User avatar
raymund_revolution
Forum Newbie
Posts: 3
Joined: Tue Aug 25, 2009 9:38 pm

Re: I know there is strip_tags() for stripping all the tags

Post by raymund_revolution »

I solved the problem already. i really appreciate your comments..Thanks. :D
Post Reply