Here's what's NOT working for me:
<?php
$string = 'I have a dog and his name is <a href="http://www.jackismydog.com">Jack</a> and I love him very much because he\'s my favorite dog in the whole wide world and nothing could make me not love him, I think.';
$limited = substr($string, 0, 100).'...';
echo $string;
?>
I want to limit the VISIBLE text to 100 characters, but using substr()
is also including the non-visible text in the limit (<a href="http://www.jackismydog.com">
and </a>
) which takes up 41 of those available 100 characters.
Is there a way to limit the text so that the word "Jack" from the link would be included in the limit, but not <a href="http://www.jackismydog.com">
or </a>
?
Edit: I want to keep the link in the string, just not count it's length towards the limit..