我有一个数组,可能包含一个或多个项目,我希望能够以电子邮件形式提交,但让它显示每一项在一个新的行,项目是用逗号分隔。
这个数组看起来像这个6,7,4-7,2-5,
到目前为止,我有这样的看法:
$in = $register_order['product_id_array'];
$out = str_replace(',', '<br />', $in);
但电子邮件显示如下:
6-7<br />4-7<br />2-5<br />
我想把它渲染成:
6-7
4-7
2-5
谢谢!
发布于 2016-07-20 21:35:13
为了用PHP发送HTML电子邮件,请执行以下操作:
$to = 'email@example.com';
$subject = 'Hello there this is my email';
$header = "From: " . $name . "\r\n";
$header .= "Reply-To: ". $email . "\r\n";
$header .= "CC: email@example.com\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=UTF-8\r\n";
$content = '<html><body>';
$content .= 'hello' . '<br />' . 'hello';
$content .= '</body></html>';
mail($to, $subject, $content, $header);
所有重要的部分都在邮件的标题部分。内容类型通知它必须作为HTML内容读取。
发布于 2016-07-20 21:32:06
如果它实际上是打印出标记<br />
,则需要将content-type
头设置为text/html
。或者,如果<br />
标记是电子邮件中唯一的HTML,那么只需用\r\n
替换它--确保\r\n
是双引号而不是单引号。
发布于 2016-07-20 21:34:49
$in = $register_order['product_id_array'];
$out = str_replace(',', '!n', $in);
或
$in = $register_order['product_id_array'];
$out = str_replace(',', '/r/n', $in);
试试这段代码
https://stackoverflow.com/questions/38491174
复制相似问题