...

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



Nealec
05-19-2011, 11:39 AM
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?

tangoforce
05-19-2011, 12: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);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum