我想检查如果道具计数 >0 发送消息,否则找不到道具


I want check whether if prop count >0 send message else no prop found

$agent_id = $this->uri->segment(3);
$this->load->model('agent_model');
$res = $this->agent_model->agentsjoin($agent_id);
foreach($res as $k=>$v){
    if($res[$k]->prop_count>0){
        echo "send message";
    }else{
        echo "no prop found";
    }
}

$res的输出为 agent_id 和 prop_count

如果$res是一个对象,你可能想尝试以下代码:

$agent_id = $this->uri->segment(3);
$this->load->model('agent_model');
$res = $this->agent_model->agentsjoin($agent_id);
foreach ($res as $k => $v) {
    if ($v->prop_count > 0) {
        echo "send message";
    } else {
        echo "no prop found";
    }
}
相关文章: