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);