我需要关于 php foreach 循环值、推送到数组和转换为 json 的帮助。
以下代码仅显示最后一个值。例如,我想超过显示的限制超过两封电子邮件。请帮我。
public executeInvite(sfWebRequest $request)
{
$email = $request->getParameter("email");
foreach($email as $e)
{
if($invitationlimit>0)
{
$q = Doctrine_Query::create()
->from ('invitationwp')
->where('email_address = ?', $em);
$this->invitedlist = $q->fetchArray();
$message ="success";
}
else
{
$emails = array();
$count = 0;
$emails[$count++] =$em;
$message = $emails;
}
$invitationlimit--;
}
return $this->renderText(json_encode($message));
}