php如何修剪heredoc中的每一行(长字符串)
发布时间:2020-12-13 17:54:14 所属栏目:PHP教程 来源:网络整理
导读:我正在寻找一个 PHP函数,可以修剪一个长字符串中的每一行. 例如: ?php$txt = HD This is text. This is text. This is text.HD;echo trimHereDoc($txt); 输出: This is text.This is text.This is text. 是的,我知道trim()函数.只是不确定如何在像heredoc
我正在寻找一个
PHP函数,可以修剪一个长字符串中的每一行.
例如: <?php $txt = <<< HD This is text. This is text. This is text. HD; echo trimHereDoc($txt); 输出: This is text. This is text. This is text. 是的,我知道trim()函数.只是不确定如何在像heredoc这样的长字符串上使用它. function trimHereDoc($t) { return implode("n",array_map('trim',explode("n",$t))); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |