Jump to content

IPSText::truncate() - exclude html from count

Featured Replies

Posted

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:

Just implemented this , I would agree :) - had to extend the truncate by a few more to take into account the html


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'>

Archived

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

Recently Browsing 0

  • No registered users viewing this page.