Jump to content

Embedded <a href> code cut short, undesired results


paruby

Recommended Posts

i have an admin page that lists all the rows from a table. One of the fields is generated using FCKEditor, so the field has HTML Code in it.  I would like to only show the first 100 or so chars of the field, but if the 100 chars ends in the middle of HTML code, specifically in this case <a href>, it cuts off, and creates "havoc" in my page.  Is there a way to avoid this by seeing that the 100 char is in the middle of an <a href> tag (or any tag for that matter?

 

Here is what the generated html can look like ::

 

<td class="tdresults">We are very excited to offer three great events at the <a href="http://www.mylongwebsite.c</td>

<td class="tdresults">next field data</td>

 

Thank you in advance.

 

Pete

 

Link to comment
Share on other sites

Regular expressions are very good for solving this type of problem.  There's also htmlentities() which will turn the html into entities.  If this is an admin system as you describe providing an informational display, htmlentities might be a great quick solution.  Once you've run it on the original string, you can concat whereever you want and have no concerns about anything being broken.

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.