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 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making Paragraphs A Minimum Length

    Hi

    I have a database driven php website, and I am looking for a way to make the first paragraph a MINIMUM length say 550 characters including spaces. The paragraph can be longer that this but not shorter, and it is to only affect the first paragraph.

    As some of our content is sourced from writers that do not follow or writing model we need a way to control this and I understand that we would need to strip all paragraph and line break tags from the first 550 characters.

    Is this possible, thank you and I look forward to your replies as this one has got me stumped

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,233
    Thanks
    51
    Thanked 100 Times in 99 Posts
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #3
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you but I do not think that these will work as from what I see none of these will display the first 550 characters and remove the paragraph and line break formatting or am I missing something.

    Which one do you think would work as I do not see which one would apply.

  • #4
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Quote Originally Posted by discomaniac View Post
    Thank you but I do not think that these will work as from what I see none of these will display the first 550 characters and remove the paragraph and line break formatting or am I missing something.

    Which one do you think would work as I do not see which one would apply.

    Try this.. it's lulzy but it worked for me

    PHP Code:
    <?php

    $str 
    "aocibedied aocibedied aocibedied aocibedied <p>aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied <br />aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied </p>aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied<br /> aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied <br />aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied aocibedied";

    if(
    strlen($str) > 550)
    {
        
    $shortened '';
        for(
    $i=0;$i<550;$i++)
        {
            
    $shortened .= $str[$i];
        }
        
        echo 
    "Length: "strlen($shortened) . "<br />";
        
    $shortened strip_tags($shortened);
        echo 
    $shortened;
    }



    ?>

  • #5
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried it but couldn't get it to work, here is the code that I used



    <?php

    $str =

    $images=getImages('articles',$info['article_id']);
    if($images){

    ;

    if(strlen($str) > 550)
    {
    $shortened = '';
    for($i=0;$i<550;$i++)
    {
    $shortened .= $str[$i];
    }

    echo "Length: ". strlen($shortened) . "<br />";
    $shortened = strip_tags($shortened);
    echo $shortened;
    }
    ?>

  • #6
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Quote Originally Posted by discomaniac View Post
    I tried it but couldn't get it to work, here is the code that I used



    <?php

    $str =

    $images=getImages('articles',$info['article_id']);
    if($images){

    ;

    if(strlen($str) > 550)
    {
    $shortened = '';
    for($i=0;$i<550;$i++)
    {
    $shortened .= $str[$i];
    }

    echo "Length: ". strlen($shortened) . "<br />";
    $shortened = strip_tags($shortened);
    echo $shortened;
    }
    ?>
    $str has to be something since its the variable that is used in the conditional......

  • #7
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you but the articles are stored in our database so do you know how I would work around this please?

  • #8
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Any ideas please?

  • #9
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    make $str = the call to your database for an article..


  •  

    Tags for this Thread

    Posting Permissions

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