我有数组
$fullname = $_POST['fullname'];
$company_name = $_POST['company_name'];
$email = $_POST['email'];
$address = $_POST['address'];
$telephone = $_POST['telephone'];
$comment = $_POST['comment'];
$data = array ( "Full Name :" => $fullname,
"Company :" => $company_name,
"email :" => $email,
"address :" => $address,
"telephone :" => $telephone,
"mobile :" => $mobile,
"comment :" => $comment);
我想要显示结果,例如(全名:$fullname电子邮件:$email)
将其作为电子邮件发送
并使用 implode("",$data) 在字符串中添加数组
我能做什么?
最佳答案
$fields = array('fullname' => 'Full Name', 'company_name' => 'Company', 'email'=>'Email', 'address' => 'Address', 'telephone'=>'Telephone', 'comment'=>'Comment');
$string = "(";
foreach($fields as $field_name => $field_label)
{
if(isset($_POST[$field_name]))
{
$string .= $field_label .' :' . $_POST[$field_name] . ' ';
}
}
$string .= ')';
关于php - 如何为每个键指定名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2267127/