Jump to content

[SOLVED] Echoing first few words... w/out displaying HTML formatting


kidreapertronV

Recommended Posts

Hello everyone,

 

I'm definitely a beginner... so I really appreciate a resource like this. Thanks!

 

I'm using MySQL v4.1, and PHP5.

 

I'm trying to echo just the first few words of a LONGTEXT string, but the string has html formatting.  Ideally, I would like to:

 

[*]display the first few words with the formatting in tact

[*]OR get PHP to ignore the html formatting completely

 

Are there any functions that can accomplish this?

 

Thanks again!

 

 

 

You can use strip_tags on your string and then grab the first few words.  That not preserve the markup though.  Could then take the last word and use some regex to grab entire original string up to last word + any tags that come after it.

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.