Php 内爆返回的第一个值不同?
我不知道为什么数组中的第一个值添加了Php 内爆返回的第一个值不同?,php,html,Php,Html,我不知道为什么数组中的第一个值添加了标记,而其余的值在li标记中运行良好 //user posted variable $checks = $_POST['personalization_result']; //handling the form data and outputting it into a list if(!empty($checks)){ $checkValues = array_values($checks); $checkString = implode('<li
标记,而其余的值在li
标记中运行良好
//user posted variable
$checks = $_POST['personalization_result'];
//handling the form data and outputting it into a list
if(!empty($checks)){
$checkValues = array_values($checks);
$checkString = implode('<li style="list-style: none;">'.get_post_meta($post->ID, '_moon_question', true).'', $checkValues);
}
// I need this filter so it can parse the html in the email
add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));
//E-mailing my form data here
$sent = wp_mail($to, $subject, $checkString, $headers);
//用户发布的变量
$checks=$\u POST['personalization\u result'];
//处理表单数据并将其输出到列表中
如果(!空($checks)){
$checkValues=数组_值($checks);
$checkString=内爆('”。获取“post”meta($post->ID,''u moon\u question',true)。'',$checkValues);
}
//我需要这个过滤器,以便它可以解析电子邮件中的html
添加过滤器('wp_邮件内容类型',创建函数('','return“text/html”);
//在此处通过电子邮件发送我的表格数据
$sent=wp_mail($to、$subject、$checkString、$headers);
这是可行的,电子邮件是发送的,但出于某种原因,它看起来像这样
<p>1</p> //this is the first value it should look like below
<li style="list-style: none;">Suits1</li>
<li style="list-style: none;">Suits1</li>
<li style="list-style: none;">Suits1</li>
<li style="list-style: none;">Suits0</li>
<li style="list-style: none;">Suits0</li>
1//这是它应该如下所示的第一个值
套装1
套装1
套装1
套装0
套装0
我希望我能找出问题所在,但坦率地说,我不确定问题在哪里?我感觉它在
内爆
中,可能HTML没有正确编写?内爆
正在给定数组的所有出现之间添加给定字符串。这意味着,您提供的输出可能不是由您给定的脚本生成的,因为任何地方都没有给定的
除此之外,没有人知道,get\u post\u meta($post->ID,'u moon\u question',true)
将返回什么,您最有可能希望生成一个列表
那么要执行的代码应该是这样的:
注意:第一个Openig和最后一个closing标签需要分开,因为内爆只会在两者之间添加。
因此,“中间字符串”需要以结束标记开始,以开始标记结束
echo "<li>".implode("</li><li>", $myArray)."</li>";
echo“”。内爆( ,$myArray)。“ ”;
太好了,这真的让人大开眼界。我用电子邮件将数据发送到一个整洁的列表中,我不得不这样写:“$checkString=””.get_post_meta($post->ID,“'u moon_question',true)。”.introde(“ ”.get_post_meta($post->ID,'u moon_question',true)。“,$checkValues)。“ ”
添加两次post\u meta
,就像
你的回答帮助我理解了这一点。谢谢@dognose