我正在使用Codeigniter和Phils RESTserver开发API。在其中一个资源中,开发人员可以发送电子邮件地址的"数组"然后在服务器上进行处理。
我怎么能,也许使用正则表达式,检查传入的"数组"是在格式如下图所示?我将使用它作为CI表单验证。
("email@example.com","anna@nicole.com")
感谢所有的帮助!
foreach ($this->post('emails') as $email)
{
if ( ! filter_var($email, FILTER_VALIDATE_EMAIL))
{
return $this->response(array('message' => 'GTFO'), 400);
}
}