Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Removing html tags from a feed

Hi guys, I have limited some text coming through a a feed to 1200 characters but there is also span tags and strong tags I need to strip out.

<?=Utils::substrwords($excerpt[0],1200,"...")?>

Is there a way I can do this with Simple Php?

Thanks in advance!

2 Answers

I believe you want the php function strip_tags. If the tags are contained in the $excerpt variable there, just do something like:

strip_tags($excerpt);

If that doesn't accomplish it, I would probably need to see more code. If it's just the span tags and strong tags, but there's other tags that you want left alone then you can add the exception:

strip_tags($excerpt, '<a><p>');

And so forth. Mess around with that and let me know.

Check out the php manual on strip_tags as well.

http://www.php.net/manual/en/function.strip-tags.php

That worked a treat thank you!