我有一个简单的 mail() 脚本,它通过用逗号分隔电子邮件来动态发送到多封电子邮件。
<?php
$sendto = array("email@gmail.com", "email@zoho.com", "email@mail.usf.edu");
foreach ($sendto as $email)
{
if ($email is the last indice in the array..) // <-- here
$to = $email;
else
$to = $email . ', ';
}
$subject = "test message";
$msg = "this is a test";
if (mail($to, $subject, $msg))
echo "message sent";
else
echo "uh oh";
?>
我如何识别(这是我数组中的最后一条数据)?