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,089
    Thanks
    51
    Thanked 506 Times in 493 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);
       } 
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!


  •  

    Posting Permissions

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