简体   繁体   中英

Store line breaks and indentation from text area

I am working on a web application where the user is given a HMTL form to complete. That form contains a text area and some checkboxes. The text from the text area is stored in the database after a call to htmlentities . The admin website then recovers that post, displays it to the administrators and if they approve it, it gets posted on a facebook page by the Facebook SDK for PHP.

The issue that I am trying to solve is that if the user's post includes line breaks or bullet lists they are not displayed in the admin website and obviously they are not posted on facebook the way they should be. It's important to note here that I don't need bold, italic or underlined text. I just want any white space the user inputs to be preserved.

Right now if the user posts this:

- First Line
   - Second Line
-Third Line

what the admin gets is this:

-First Line - Second Line - Third Line

So basically I need functionality similar to that of a Google Form. The admin should be able to see every white space and that white space should also be preserved when the post gets posted on Facebook either by copy-paste or by the API.

I think this is because your result that admin see is outputted in HTML format with \\n symbols and not br's. Try this:

echo nl2br($str);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM