分解结果并将它们分配给变量

Explode a result and Assign them to a Variables

我有一个输入字段,其中包含不同的电子邮件地址。我希望能够在提交时循环遍历此输入,并将每个输入分配给一个变量,这样我就可以使用它们进行处理。查看我的代码并告诉我我在哪里遗漏了它:

<input type="email" name="m" placeholder-"Enter Email address separated by (;)"/>
<input type="submit" name="sbt" value="Submit"/>

<?php
if($_POST['sbt']){
$myMail = $_POST['m'];
$res = explode(";",$myMail);
foreach($res as $ml=>$value){
echo '$us'.$ml."=".$value.";<br/>"; 
}   
}
?>

I want the result to be :$us0 = ade.yemi@yahoo.com;
$us1 = ade.yemi@yahoo.com;
$us2 = nifemi.ola@gmail.com;
but it is show undefined variables for $us0;$us1;$us2. 

请帮忙或是否有更好的方法,因为我想在 phpmailer 中将这些变量用于 CC 方面。

这一行:$res = explode(";",$myMail); 将为您提供一个包含所有电子邮件地址的数组,例如:

[
   0 => 'some-address@example.com', 
   1 => 'another@example.com', 
   ...
]. 

为什么不直接使用那个数组?

像这样获取您需要的电子邮件地址:

$phpMailer->addCC($res[0]);
$phpMailer->addCC($res[1]); // Or what the syntax for PHPMailer is...