line breaks in a textarea

前端 未结 13 1666
北荒
北荒 2020-11-27 17:58

I know when saving a textarea you can use the nl2br() or str_replace to change the /n to br tags etc. However what im not sure about how to insert line breaks into a textare

13条回答
  •  借酒劲吻你
    2020-11-27 18:13

    PHP Side: from Textarea string to PHP string

    $newList = ereg_replace( "\n",'|', $_POST['theTextareaContents']);
    

    PHP Side: PHP string back to TextArea string:

    $list = str_replace('|', '
    ', $r['db_field_name']);
    

提交回复
热议问题