Jump to content

IPSText::truncate() - exclude html from count


Guest

Recommended Posts

When I do a


IPSText::truncate( $s['s_message'], 100 );



If there is html in the startup it is counted towards the length of the string. This means that the shortened text (visually) can be dramatically less than the required number of characters. What I think needs to happen is that the tags need to be stripped and the offset calculated without the html and then that offset translated into the formatted string. I know easy for me to say :tongue:

Link to comment
Share on other sites


When I do a


IPSText::truncate( $s['s_message'], 100 );

If there is html in the startup it is counted towards the length of the string. This means that the shortened text (visually) can be dramatically less than the required number of characters. What I think needs to happen is that the tags need to be stripped and the offset calculated without the html and then that offset translated into the formatted string. I know easy for me to say :tongue:

You should never truncate raw HTML text. Really funny things happen when you end up with something like

hello this is some text and here is a <a href='http://www.google.com'>

Link to comment
Share on other sites

Archived

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...