【问题标题】:PHP array with words separated by commas用逗号分隔单词的 PHP 数组
【发布时间】:2014-03-31 10:51:45
【问题描述】:

我正在使用一个数组来发送表单邮件。该数组包含表单中每个字段选项的主题。

array("0",""),
array("1","Subject 1a, Text","Subject 1b","Subject 1c"),
array("2","Subject 2a","Subject 2b","Subject 2c")

当表单交付给客户时,主题行显示“Form: Subject xx”。

$subject = "Form: ".$value[1]; 

但是,如果主题包含逗号,如第一个示例中所示(即“主题 1a,文本”),则提交的表单仅在主题字段中包含 Form: Subject 1a

它不会发送带有逗号及其后面的单词的完整主题行(即Form:Subject 1a,Text)。

对可能发生的事情有什么想法吗?

【问题讨论】:

  • $value 来自哪里?
  • 需要更多信息。您如何将$subject 传递到邮件实用程序,以及如何生成$value
  • 您可以使用 fputcsv() 将转义字符更改为 "

标签: php html forms email


【解决方案1】:

这样的东西应该可以工作

iconv_set_encoding("internal_encoding", "UTF-8");

$subject = "Testmail — Special Characters";
$msg = "Hi there,\n\nthis isn’t something easy.\n\nI haven’t thought that it’s that complicated!";

mail(utf8_decode($to), utf8_decode($subject), utf8_decode($msg), utf8_decode($from)."\nContent-    Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n");?>

正确进行编码/解码。 引用自php mail special characters utf8

【讨论】:

  • 我不认为这与手头的问题有关 - 电子邮件中的字符很好
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多