I am looking for some tutorial how to do this, but can not find.

Some users are spamming my site submitting text like:

"xxxxxxxxxxxxxxxxx +++++++++++++++ oooooooooooooooooooo"

I want that if a charachter repeats more than 3 times, other characters are being deleted. So, if an users enters text like in the example above, the output will be:

"xxx +++ ooo".

One more thing I am looking for is how to remove multiple <br> between lines.

    Thanks. I use preg_replace to remove html tags and know your reccomended tutorials.

    The problem is that I dont know a lot about \r\n things. I experimented many times, but no result...

    My users can attach some text to their profiles. What I want is:

    if an user press "Enter" one time when typing text, the result is <br>.

    If an user press "Enter" 2 times, the result is <p>.

    So, I want to keep some formatting, but I don't want that an user can press "Enter", lets say, 100 times creating a large blank page.

    Please see the function below. It works, but the problem s that it filters text so that there are no <p> anymore (for example, if I press "Enter" 10 times the result after filtering is one <br> but not <p>.

    Sorry for my English. I hope you understand what I mean.

    I searched many php tutorials but still can not find hot to replace several spaces between words with a single space. I know it's a preg_replace issue too...

    $search = array ("'<script[>]?>.?</script>'si",
    "'<[\/!]?[<>]?>'si",
    "'([\r\n])[\s]+'",
    "'&(quot|#34);'i",
    "'&(amp|#38);'i",
    "'&(lt|#60);'i",
    "'&(gt|#62);'i",
    "'&(nbsp|#160);'i",
    "'&(iexcl|#161);'i",
    "'&(cent|#162);'i",
    "'&(pound|#163);'i",
    "'&(copy|#169);'i",
    "'&#(\d+);'e");

    $replace = array ("",
    "",
    "\1",
    "\"",
    "&",
    "<",
    ">",
    " ",
    chr(161),
    chr(162),
    chr(163),
    chr(169),
    "chr(\1)");

    $profile = preg_replace($search, $replace, $profile);

      That I dont know too much about to be honest. All I can think is try to set a variable like this

      $enters = '

      ';

      I dont know if I am explaining this correctly or not, but basically add a variable into your array and hit <enter> 3 times.

        Read the Unix man page that explains regular expressions (man 7 regex) and pay particular attention to the definitions of branch, piece, bound, and atom.

        ((\r\n){4,99}) matches any sequence of 4 to 99 CRLF pairs.

          Write a Reply...