0
我有一個聯繫人,假設您將電子郵件作爲下拉選項發送給不同的人。如何調用數組中的數組值+ foreach
選項值在數組中使用數組定義,我正在努力調用數組值,以便電子郵件可以轉到指定的人。
數組定義如下:
if((isset($_GET['enquiry']) && $_GET['enquiry']=='Locate a dealer/distributor')||(isset($_POST['enquiry']) && $_POST['enquiry']=='Locate a dealer/distributor')){
$chk_Locate=TRUE;
}
if(isset($_GET['enquiry']) && $_GET['enquiry'] == 'CC'){
$query_recipients = array(array('Complaint', '[email protected]'),
array('Suggestion', '[email protected]'),
array('Compliment', '[email protected]'));
$enquiry = '<input type="hidden" name="enquiry" id="enquiry" value="CC">';
}
else{
$query_recipients = array(array('Locate a dealer/distributor', '[email protected]'),
array('Technical support', '[email protected]'),
array('Back orders', '[email protected]'),
array('Product enquiry', '[email protected]'),
array('Catalog request', '[email protected]'),
array('New customer enquiry', '[email protected]'),
array('Existing customers - logon', '[email protected]'),
array('Existing customers - orders', '[email protected]'),
array('Report web problems', '[email protected]'));
}
環
foreach($query_recipients as $key => $val){
if((isset($_POST['enquiry']) && $_POST['enquiry'] == $val[0])||(isset($_GET['enquiry']) && $_GET['enquiry'] == $val[0])){
$selected = $val[0].' : '.$item;
if($val[0]=='Existing customers - logon'||$val[0]=='Technical support'||$val[0]=='Catalog request'||$val[0]=='Product enquiry'||$val[0]=='New customer enquiry'||$val[0]=='Existing customers - orders'||$val[0]=='Catalog request')
調用它們的代碼是:
$_POST['recipient_email'] = $contact_email.','.$recpt_email;
if(isset($ref_number)){
$_POST['subject'] = 'Examplecompany Group: '.$ref_number.': '.$_POST['enquiry'];
}else{
$_POST['subject'] = 'Examplecompany Group: '.$_POST['enquiry'];
}
$_POST['sender_email'] = $_POST['email'];
$_POST['cc'] = $_POST['email'].', Examplecompany Group <[email protected]>';
$_POST['body'] = '<p>Name: ' . $_POST['name'] . '</p>'
. '<p>Surname: ' . $_POST['surname'] . '</p>'
. '<p>Company: ' . $_POST['company'] . '</p>'
. '<p>Examplecompany Account No.: ' . $_POST['accnr'] . '</p>'
. '<p>Account No. verification: ' . $cust_verify . '</p>'
. '<p>Email: ' . $_POST['email'] . '</p>'
. '<p>Tel/cell: ' . $_POST['tel'] . '</p>'
. $_POST['enquiry'] . ': ' . $_POST['message'];
if(Email::Send($_POST, NULL)){
$message = 'Your feedback has been sent'.$cont_ref;
} else {
$message = 'There was an error sending your feedback';
}
}
這條線我想用來稱它們爲$_POST['recipient_email'] = $contact_email.','.$recpt_email;
現在它可以工作,但它會調用最後一個數組array('Report web problems', '[email protected]')
,而不考慮所選的選項。
請幫助,如果我能找到一種方法來調用數組的值,我相信我的形式與工作按計劃。
有,我不明白
$enquiry_options .= '<option>'.$val[0].'</option>';
$recpt_email = $val[1];
如果VAL被設置爲$Val[1]
形式發送電子郵件給數組的最後一個電子郵件地址,但如果設置爲$Val[0]
它不一行。
您是否考慮過使用鍵值對而不是嵌套數組?例如,'array('Complaint'=>'[email protected]','Suggestion'=>'[email protected]')'。見http://php.net/manual/en/language.types.array.php – user113215
感謝您的輸入,我會檢查出來並反饋。 – Mlungisi
感謝您的輸入,是的,我試過了,頁面確實加載。我不是原始編碼器,並且似乎不知道原始編碼器在這裏指定了什麼:$ recpt_email = $ val [1]; – Mlungisi