PHP-如何在表单中为每个选中的复选框添加标记
有人知道如何使用纯PHP为每个选中的复选框添加标记吗?我的表单与集成。(您不必熟悉API) 一切都很正常,但键(标记)返回一个字符串,其中包含所有值(兴趣),由列分隔PHP-如何在表单中为每个选中的复选框添加标记,php,forms,api,customization,Php,Forms,Api,Customization,有人知道如何使用纯PHP为每个选中的复选框添加标记吗?我的表单与集成。(您不必熟悉API) 一切都很正常,但键(标记)返回一个字符串,其中包含所有值(兴趣),由列分隔 $interests_val = $_POST['interests_val']; $contact = array( "email" => $user_info->user_email, "tags[0]"
$interests_val = $_POST['interests_val'];
$contact = array(
"email" => $user_info->user_email,
"tags[0]" => "[Interest] ".implode(", ", $interests_val),
);
相反,我想为每个选定的值或复选框添加一个标记。有没有办法更有效地执行此操作?我有20多个复选框
$interests_val = $_POST['interests_val'];
$contact = array(
"email" => $user_info->user_email,
"tags[0]" => "[Interest] ".$interests_val[0]),
"tags[1]" => "[Interest] ".$interests_val[1]),
"tags[2]" => "[Interest] ".$interests_val[2]),
);
谢谢 尝试在您的
$interests\u val
上使用循环,并在创建带有固定值的$contact
数组(email
)后,动态创建其他密钥:
$interests_val=implode($_POST['interests_val']);
$contact = array("email"=> $user_info->user_email);
foreach($interests_val as $key=>$value){
$contact["tags{$key}"] = "[Interest] {$value}";
}
谢谢,但它似乎不起作用。它不会返回标签。有没有其他方法可以做到这一点?