Jump to content

enter key replacement...


blueman378

Recommended Posts

hi guys, well im not sure if it belongs here but i want to be able to do it in php, anyway i was wondering how would i go about when you press enter in the textbox it adds a new line, thats a normal thing to happen, but this isnt sent to the form as input so if i had

 

some content

 

 

 

some more

 

it would read as

some content some more,

 

how would i make it so that when there are enters it reads them to, i was using javascript before to simply insert a newline thing but that looked ugly and am wondering if there is a better way?, same as how phpfreaks does it is what im looking for

Link to comment
https://forums.phpfreaks.com/topic/97202-enter-key-replacement/
Share on other sites

It's the same thing happens when writing HTML, pressing enter won't cause line breaks when you view the page in a browser. You have to change the line breaks to <br />. PHP has a function for this called nl2br. It takes 1 string as an argument and returns the same string with newlines changed to <br />'s.

Link to comment
https://forums.phpfreaks.com/topic/97202-enter-key-replacement/#findComment-497374
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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