Codeigniter搜索特定阵列中的用户

时间:2014-08-23 23:32:17

标签: php arrays codeigniter

大家好,请帮帮我!!! 我想要的是我想检查登录用户是否存在于给定数组中是否是控制器在代码点火器中返回的数组,其中包含用户数据以及JSON格式如下所示的市场: 它是使用json_encode()函数的数组输出。

[
{
    "id":23,
        "user":{
            "id":2,
            "name":"Yubraj Pokharel",
            ...
        },
        "market":{
            "id":1,
            "name":"Penty & Bra SHop",
            "city":"Kathmandu",
            "street":"Ghattekulo-32",
            ....
        }
}

]

我尝试通过执行某些给定的东西来检查用户是否存在于给定数组中:

foreach($followers as $users):
    if(isset($this->session->userdata['logged_in'])){
        if ($users->user->id == $this->session->userdata['logged_in']['id']){
            echo "You are Following this shop";
        }else {
            echo "You are Not";
        }
    }else{echo 'Not Logged in';}
    endforeach;

0 个答案:

没有答案