Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.