How to substr html entities properly?

Posted by Emily on Stack Overflow See other posts from Stack Overflow or by Emily
Published on 2010-04-17T04:15:35Z Indexed on 2010/04/17 4:23 UTC
Read the original article Hit count: 262

Filed under:
|

Hi everyone.

I have like this :

$mytext="that's really "confusing" and <absolutly> silly";
echo substr($mytext,0,6);

The output in this case will be : that&# instead of that's

What i want is to count html entities as 1 character then substr, because i always end up with breaked html or some obscure characters at the end of text.

Please don't suggest me to html decode it then substr then encode it, i want a clean method :)

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about html-entities