robert_gsfame Posted April 23, 2010 Share Posted April 23, 2010 I pass the value from php code into javascript function and i have <textarea> where i put inside innerHTML, but i have this <br /> always attached when new line created although i have decode the value using unescape() how can i erase the <br /> Link to comment https://forums.phpfreaks.com/topic/199455-remove-from-textarea/ Share on other sites More sharing options...
callesson Posted April 23, 2010 Share Posted April 23, 2010 http://www.knowledgesutra.com/index.php/Remove-Ltbr-Gt-Tags-Textarea-Data_t18950.html ? Link to comment https://forums.phpfreaks.com/topic/199455-remove-from-textarea/#findComment-1046851 Share on other sites More sharing options...
xenophobia Posted April 23, 2010 Share Posted April 23, 2010 You need to filter your output before printing to the textarea. You need this to convert the <br /> tag to a newline: <?php function br2nl($string){ $return=eregi_replace('<br[[:space:]]*/?'. '[[:space:]]*>',chr(13).chr(10),$string); return $return; } ?> Its a reverse function of nl2br. Once you filtered your output, then only you print to your textarea. Link to comment https://forums.phpfreaks.com/topic/199455-remove-from-textarea/#findComment-1046853 Share on other sites More sharing options...
Ken2k7 Posted April 23, 2010 Share Posted April 23, 2010 eregi_replace is deprecated and should no longer be used. Also, doesn't php have a nl2br function? Link to comment https://forums.phpfreaks.com/topic/199455-remove-from-textarea/#findComment-1047172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.