Continue in the next page?

Discussion in 'PHP' started by red-x, Sep 16, 2008.

  1. #1
    Hi, how can I echo something and if its very long lets say 200 words it will put dots at the end of the 200 words article and display a keep reading link to another page like

    I'm not sure if you guys know what I mean :eek:

    Thanks in advance for any help :)
     
    red-x, Sep 16, 2008 IP
  2. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #2
    hi, there are many ways to do this..

    if you want just
    echo substr('abcdef', 0, 3); // abc

    or you can use pagination.
     
    bartolay13, Sep 17, 2008 IP
  3. red-x

    red-x Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi, thanks but but how can I do this..

    $article = $_POST["article"];
    $article_sub = substr($article, 0 , 200);
    
    if ($article_sub) {echo $article . '...Continue reading';} else {echo $article;} 
    PHP:
    So if $article_sub == true, if its has more than 200 words on it, I want to echo at the end of the article ... Continue reading. else if the article doesn't have 200 then just echo the $article?
     
    red-x, Sep 17, 2008 IP
  4. lui2603

    lui2603 Peon

    Messages:
    729
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can use strlen() to check the length of the article like

    
    if(strlen($article) > 200){
     echo substr($article, 0, 200).'... continue reading';
    }
    else{
     echo $article;
    }
    
    PHP:
     
    lui2603, Sep 17, 2008 IP
  5. red-x

    red-x Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks that works :)
     
    red-x, Sep 17, 2008 IP