Page 1 of 1
I know there is strip_tags() for stripping all the tags
Posted: Tue Aug 25, 2009 9:57 pm
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
Re: I know there is strip_tags() for stripping all the tags
Posted: Tue Aug 25, 2009 10:17 pm
by requinix
raymund_revolution wrote:Here' my code:
No, that's not your code. Try posting it again?
Re: I know there is strip_tags() for stripping all the tags
Posted: Tue Aug 25, 2009 11:43 pm
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
Re: I know there is strip_tags() for stripping all the tags
Posted: Tue Aug 25, 2009 11:52 pm
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?
Re: I know there is strip_tags() for stripping all the tags
Posted: Wed Aug 26, 2009 6:29 am
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.
Re: I know there is strip_tags() for stripping all the tags
Posted: Wed Aug 26, 2009 10:14 pm
by raymund_revolution
I solved the problem already. i really appreciate your comments..Thanks.
