Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-19-2011, 11:39 AM   PM User | #1
Nealec
New Coder

 
Join Date: Feb 2011
Posts: 95
Thanks: 7
Thanked 0 Times in 0 Posts
Nealec is an unknown quantity at this point
Read more... if text more than 600 charcters

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?
Nealec is offline   Reply With Quote
Old 05-19-2011, 12:17 PM   PM User | #2
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,505
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Hi Nealec, glad to see you're still at it

I think this would be suited to the 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:
PHP Code:
$Test 'teslkjlfgjg oigjsd ofjslfjsdfjsdlfjsdiofjslk nslkfj lsdkfj sdlfjdlskf jk';

if (
strlen($Test) > 10)
   {
   print 
substr($Test010);
   } 
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:48 AM.


Advertisement
Log in to turn off these ads.