Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2011
    Posts
    95
    Thanks
    7
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,364
    Thanks
    61
    Thanked 530 Times in 517 Posts
    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);
       } 
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •