Check if a specific value exists at a specific key in any subarray of a multidimensional array

前端 未结 13 2103
梦毁少年i
梦毁少年i 2020-11-27 18:42

I need to search a multidimensional array for a specific value in any of the indexed subarrays.

In other words, I need to check a single column of the multidimension

相关标签:
13条回答
  • 2020-11-27 19:32

    You can use this with only two parameter

    function whatever($array, $val) {
        foreach ($array as $item)
            if (isset($item) && in_array($val,$item))
                return 1;
        return 0;
    }
    
    0 讨论(0)
提交回复
热议问题