How to ??????? HELP

Discussion in 'PHP' started by Dakuipje, Oct 14, 2007.

  1. #1
    Ok im busy coding myself a website and part of it is a comment system.

    Now what I dont want is comment with a lot of enters:

    But I do need the ability to post an enter.



    I want to limit the ammount to 2 enters (<br>'s)
    But something like this should be allowed:

    But not


    Is there a way ????
     
    Dakuipje, Oct 14, 2007 IP
  2. jnestor

    jnestor Peon

    Messages:
    133
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can do something like:

    preg_replace("/<br><br>([<br>]*)/","<br><br>",

    but it's not going to work well since people can easily add a space to a line which will make it look blank.
     
    jnestor, Oct 14, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    
    $text = preg_replace('/[\r\n]{3,}/', "\n\n", $text);
    
    PHP:
    This will do it.
     
    nico_swd, Oct 14, 2007 IP
    Dakuipje likes this.
  4. Dakuipje

    Dakuipje Peon

    Messages:
    931
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yeah that worked great :D
    Thanx a lot !!!


    (green rep)
     
    Dakuipje, Oct 15, 2007 IP