Jump to content

Cleaning new lines


Manixat
Go to solution Solved by Manixat,

Recommended Posts

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 ...

Edited by Manixat
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.