首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用php从文本区域中删除\r\n\r\n

如何使用php从文本区域中删除\r\n\r\n
EN

Stack Overflow用户
提问于 2018-10-24 18:25:34
回答 2查看 178关注 0票数 0

我无法使用以下任何方法从文本区域中删除这些"\r\n\r\n“

代码语言:javascript
复制
Good job overall!\r\n\r\n*********************************************************************** \r\n\r\nSoft skills: Please don\'t forget to ask customers for the reason of cancellation.

代码语言:javascript
复制
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

( =>阵列( field_id => 5497类型=> F parent_id => 0 field_type => field_name => Retention Offered?required => 1 maxlength => 0 field_value => YES not_applicable => on (所需的最大长度为0=>not_applicable=>on)

代码语言:javascript
复制
[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
    )

)

EN

回答 2

Stack Overflow用户

发布于 2018-10-24 18:29:20

用户preg_replace,要从字符串中删除\n\r,请遵循以下代码

代码语言:javascript
复制
$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;
票数 0
EN

Stack Overflow用户

发布于 2018-10-24 19:20:41

我使用了下面的代码( '\t','\n','\r‘),只是使用了单引号而不是双引号

代码语言:javascript
复制
$snip = str_replace('\t', '', $snip); // remove tabs
$snip = str_replace('\n', '', $snip); // remove new lines
$snip = str_replace('\r', '', $snip); // remove carriage returns
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52966614

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档