[英]how to remove \r\n\r\n from an textarea using php
I am not able to remove these "\\r\\n\\r\\n" from textarea using any of below method 我无法使用以下任何一种方法从文本区域中删除这些“ \\ r \\ n \\ r \\ n”
Good job overall!\r\n\r\n*********************************************************************** \r\n\r\nSoft skills: Please don\'t forget to ask customers for the reason of cancellation.
methods
$resolution = trim($resolution);
//Effort 2
$resolution = nl2br($resolution);
//Effort 3
$resolution = htmlentities($resolution);
//Effort 4
$resolution = preg_replace("\\r\\n","<br>",$resolution);
$snip = str_replace("\t", '', $snip); // remove tabs
$snip = str_replace("\n", '', $snip); // remove new lines
$snip = str_replace("\r", '', $snip); // remove carriage returns
Array
( [0] => Array ( [field_id] => 5497 [type] => F [parent_id] => 0 [field_type] => selectbox [field_name] => Retention Offered? [required] => 1 [maxlength] => 0 [field_value] => YES [not_applicable] => on ) ([0] =>数组([field_id] => 5497 [type] => F [parent_id] => 0 [field_type] => selectbox [field_name] =>提供的保留时间?[必需] => 1 [最大长度] = > 0 [field_value] =>是[not_applicable] => on)
[1] => Array
(
[field_id] => 5494
[type] => F
[parent_id] => 0
[field_type] => textarea
[field_name] => Summary of Interaction
[required] => 1
[maxlength] => 0
[field_value] => Cx requested cancel, agent secured and explained account, offered rates, cx declined, agent confirmed cancellation
[not_applicable] => on
)
[2] => Array
(
[field_id] => 5495
[type] => F
[parent_id] => 0
[field_type] => textarea
[field_name] => Feedback
[required] => 0
[maxlength] => 0
[field_value] => Good job overall!\r\n\r\n*********************************************************************** \r\n\r\nSoft skills: Please don\'t forget to ask customers for the reason of cancellation.
[not_applicable] => on
)
) )
user preg_replace , To remove \\n\\r from a string, follow the below code 用户preg_replace ,要从字符串中删除\\ n \\ r ,请遵循以下代码
$title = "Good job overall!\r\n\r\n*********************************************************************** \r\n\r\nSoft skills: Please don't forget to ask customers for the reason of cancellation";
$new_title = preg_replace("/[\n\r]/","",$title);
echo $new_title;
I done this using below code , ( '\\t', '\\n', '\\r' ) just used single quotes instead of double quotes 我使用以下代码完成了此操作,('\\ t','\\ n','\\ r')仅使用单引号而不是双引号
$snip = str_replace('\t', '', $snip); // remove tabs
$snip = str_replace('\n', '', $snip); // remove new lines
$snip = str_replace('\r', '', $snip); // remove carriage returns
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.