View Full Version : Read more... if text more than 600 charcters

05-19-2011, 12:39 PM
I am wanting to display large text blocks from a database but i would like to stop the text if its longer than 600 characters and display Read more... as a link.

Can someone please help me?

05-19-2011, 01:17 PM
Hi Nealec, glad to see you're still at it ;)

I think this would be suited to the str_len (http://uk2.php.net/str_len) function. I say think because i don't know how it handles large texts from mysql etc.

The following worked well for me when i ran it through my code tester - change the 10 to 600:

$Test = 'teslkjlfgjg oigjsd ofjslfjsdfjsdlfjsdiofjslk nslkfj lsdkfj sdlfjdlskf jk';

if (strlen($Test) > 10)
print substr($Test, 0, 10);