Jump to content

Extracting a paragraph (minus the HTML)


tHud

Recommended Posts

Hello :)

 

$row[longdescription] contains a description of a product (complete with HTML mark-up).

 

I would like to display the first 250 characters in the results of a search. I would also like to remove any images that may crop up.

 

This is what I have so far...

echo strip_tags(html_entity_decode(substr(preg_replace('/<img[^>]*>/Ui', '', $row[longdescription]), 0, 250)));

 

The thing is (as you guys can probably already see), it also counts the HTML mark-up as characters and I get very different outputs (especially if an image occurs).

 

I'd appreciate if you could advise me as to the correct way of doing this.

 

Thank you :)

 

Link to comment
Share on other sites

Hi :)

 

Unfortunately not.

This is what the output looks like...

 

<div style="padding-bottom: 10px"> <strong><span class="bodyTitle themeColor">Seamless information workflow and dahdah monitoring </span></strong><br /> <br /> dah dah dah

 

Link to comment
Share on other sites

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.