Jump to content

[SOLVED] How to remove the text in <> characters.


ted_chou12

Recommended Posts

I want to remove the text using ereg_replace or something like that in the <> characters so all the html codes within the texts are gone, such that:

text <b>is</b> bold. This is a <a href="link.php">link</a>.

becomes:

text is bold. This is a link.

Thanks

Ted.

Have you tried this yourself yet?  It's an easy one.

 


$text = preg_replace('/<.*?>/','',$text);

 

< is a literal opening angle bracket.

. means ANY character

* means zero or more of the previous character

? means "don't be greedy about that, though"

> is a literal closing angle bracket

 

(I'm not entirely familiar with the POSIX regular expression syntax, so I gave you the preg one.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.