Pls I am working on a website, an email website, but when I displayed the message from the database, how can I echo out only the first 26 characters from database and also add read more so that if the read more is clicked. It will display the full text
Asked
Active
Viewed 51 times
-3
-
`substr(string,start,length)` on `$result` – Shawn Mehan May 27 '17 at 00:17
-
http://php.net/manual/en/function.substr.php – Tim Morton May 27 '17 at 00:18
-
But how can I add read more in it like in a blog – user7842101 May 27 '17 at 00:19
-
Possible duplicate of [limit text length in php and provide 'Read more' link](https://stackoverflow.com/questions/4258557/limit-text-length-in-php-and-provide-read-more-link) – Maher May 28 '17 at 07:48
2 Answers
0
You can use sbstr() function:
if (strlen($result) > 26)
echo substr($result, 0, 26) . '...';

T. AKROUT
- 1,719
- 8
- 18
0
two steps: 1.decide the length of the content using the substr() function, cut it off if it's more than the designated length and append an "......" behind while hiding the rest content,otherwise, display the whole content. 2.when click on the "read more",display the hidden part of the content

Jarvis
- 1
- 1