Codeigniter在结果数组中搜索值


Codeigniter search for a value inside result array

我可以使用哪个函数来检查结果数组中是否存在值?我试了以下方法,但失败了。

$query = $this->db->query($query);
        $result = $query->result_array();
        if (in_array('Receive', $result)) {
            echo 'this array contains Receive';
        }

试试这个

echo $this->db->last_query();

它将显示您执行的最后一个查询。把它放在你的函数末尾。

编辑:

对不起,我以为你在问这个问题,我的错。但是,如果您想知道查询是否返回了数组形式的值,可以使用:

$result = $query->result_array();
print_r($result);