wispas Posted January 5, 2010 Share Posted January 5, 2010 I currently have a script that will limit the amount of words string. instead i want it to display all of the text upon clicking a read more link at the end. is this possible with php? Link to comment https://forums.phpfreaks.com/topic/187323-string-length-limit-and-reveal/ Share on other sites More sharing options...
wispas Posted January 5, 2010 Author Share Posted January 5, 2010 <?php // Limit $summary to how many characters? $limit = 57; $summary = <<< summary Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text Text summary; if (strlen($summary) > $limit) $summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), ' ')) . '...'; echo $summary; function bigone() { $limit = 100; echo $summary; } ?> Link to comment https://forums.phpfreaks.com/topic/187323-string-length-limit-and-reveal/#findComment-989174 Share on other sites More sharing options...
monkeypaw201 Posted January 5, 2010 Share Posted January 5, 2010 You can use a bit of javascript (http://llizard.etherwork.net/cwc/showhide.html) along with PHP's substr() function (http://php.net/manual/en/function.substr.php). Link to comment https://forums.phpfreaks.com/topic/187323-string-length-limit-and-reveal/#findComment-989227 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.