检查一个值是否存在于result_array() [英] Check if a value exists in a result_array()

查看:114
本文介绍了检查一个值是否存在于result_array()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下查询....

I have the following query ....

$query = "SELECT * FROM crescent.main_stock where transaction_type like '%Receive%' LIMIT 0,1;";
        $query = $this->db->query($query);
        $result = $query->result_array();
        if (in_array('Receive', $result)) {
            echo 'this array contains Receive';
        }



我试图检查一个值Receive是否存在于result_array什么是实现这个的最好的方法?我应该使用哪个函数来检查?

I am trying to check if a value Receive exists inside the result_array(), What is the best way to implement this? Which function should I use to check ?

推荐答案

如果你想知道你的查询是否以数组的形式返回一个值,你可以把它放在最后的功能:

If you want to know if your query returned a value in the form of an array, you can put this at the end of your function:

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

这篇关于检查一个值是否存在于result_array()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆