Jump to content

Line breaks from textarea


peuge

Recommended Posts

Hi all,

 

I have a small app, which takes a users input from a textarea, what I am doing is using javasctipt onkeyup to update a preview area by sending the new data to preview.php, the problem is that if a user presses 'enter' my preview.php file is not picking up those line breaks up? All other text is fine

 

I have tried using these: $text being the get variable.

//THIS
echo nl2br($text);

//AND THIS - with \r \n and \r\n
$textArr = str_split($text,1);	
foreach ($textArr as $text){
  $text = ($text == '\r\n') ? $text = '<br/>' : $text = $text;
  echo $text;
}

I do not need to preserve copy and paste text, just when a user is simply typing in the textarea

 

Any help much appreciated

 

Link to comment
https://forums.phpfreaks.com/topic/152515-line-breaks-from-textarea/
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.