Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Cleaning new lines

$
0
0

Hello freaks,

 

I have a textarea for writing comments where users can input many new lines and I'm trying to clean those lines but nothing seems to be working. I went all over all google results and tried every example both with preg replace and str replace and nothing seems to work. What I'm doing is first escaping the comment string then trim(preg_replace()). Am I doing the order wrong or idk what might be wrong. I tried like at least 20 syntaxes and none worked, and that's when I write a comment like

 

"asd

 

 

 

 

 

asd"

 

if I write a comment like 

 

"asd

 

 

 

 

 

 

"

 

then the new lines are gone in the display of the comment but are still saved in the database which I do not want ...


Viewing all articles
Browse latest Browse all 13200

Trending Articles