I've a div with text inside that is displayed using PHP & MySQL, the structure is like this:
<div class=description>
<p>
Here is a lot of text.
</p>
</div>
I want to display a Read more link when the text inside the p-tag is more than 100 characters. I can display the Read more link with PHP like this:
// strip tags to avoid breaking any html
$string = strip_tags($string);
if (strlen($string) > 100) {
// truncate string
$stringCut = substr($string, 0, 100);
// make sure it ends in a word so assassinate doesn't become ass...
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... <a href=/this/story>Read More</a>';
}
echo $string;
The problem is that when the link is clicked I want to show all of the text in the same DIV. Is this possible with PHP or do I need jQuery or something?