我有一个字符串说
$result = \nHey there!Listen\n\n===\n\nLife is one\n\n===\n\nBut cs is 1.6ok\n\n===\n\nI hope you got what i wanna say\n\nSpeech finished\n\n===\n
现在我想
在上面的字符串中找出\n
的出现次数。我使用了以下功能,但没有输出任何内容:
substr_count($result,"\n");
我想以$result
作为电子邮件正文发送电子邮件,但\n
字符会按原样显示。
无论如何,我可以摆脱这些\n
字符,它们实际上被电子邮件主题中的新行替换了?
答案 0 :(得分:0)
$ result = str_replace(" \ n",chr(13),$ result);
我用chr(13)替换了所有\ n字符,这些字符被解释为enter。
所以它对我来说很有用:)