0

这是我的登录功能代码:

for($i=0;$i<count($this->form['customer_info']);$i++)
{
    if($value['customer_id']==$this->form['customer_info'][$i]['customer_id'] && $value['customer_pw']==$this->form['customer_info'][$i]['customer_password'])
    {
        //my code
    }
    else
    {
        //my code
    }
}

这是里面的值:$this->form['customer_info']:

Array
(
[0] => Array
    (
        [customer_id] => 1
        [customer_company] => 123
        [customer_email] => 123@123.com
        [billing_address] => 
        [contact_info] => 
        [customer_password] => k41Y6fgW
    )

[1] => Array
    (
        [customer_id] => 2
        [customer_company] => abc
        [customer_email] => abc@abc.com
        [billing_address] => 
        [contact_info] => 
        [customer_password] => XwhcCWdx
    )

[2] => Array
    (
        [customer_id] => 3
        [customer_company] => 345
        [customer_email] => 345@345.com
        [billing_address] => 
        [contact_info] => 
        [customer_password] => gaKp3b5K
    )
)

只有第一个数组[0]的信息能够被验证,其余的都不是..我真的不知道..请帮助我......非常感谢!

4

1 回答 1

0

您应该检查中的值$value['customer_id']是否与中的结果相同$info['customer_id']。如果它们相同(确保它们的顺序相同),则检查计数$this->form['customer_info']是否真的大于 0。如果这一切都不起作用,请尝试按照 Shikiryu 的建议使用 foreach。

foreach($this->form['customer_info'] as $info) {
    if($value['customer_id'] == $info['customer_id'] && $value['customer_pw'] == $info['customer_password']) {
        //your code
    } else {
        //your code
    } 
}
于 2013-10-01T09:51:18.040 回答