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

williamrossi
williamrossi
6,232 Points

Removing <div> and <br> tags from a feed

Hi guys, I am using this to feed through date, but I need to a few things and my php is super basic so getting very confused with all I need to do..

So I need to limit the characters to 1200 (which I have done)

but I also need to remove div and br tags from it, sadly this is something I can't remove with what have been given.

here is my code

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

The php part of tracks awaits me! thanks in advance

1 Answer

Michael Austin
PLUS
Michael Austin
Courses Plus Student 7,814 Points

Hi,

There’s a PHP function called strip_tags that you could use. This will remove all HTML tags from the entity you pass it. In the case of your code I’m not sure what the Utils::substrwords lark is, as you can write the code without any additional libraries (or it may be a hole in my knowledge :D):

<?php
$newData = strip_tags(substr($excerpt[0],0,1200)).&hellip;;
?>