How to check if a specific value exists at a specific key in any subarray of a multidimensional array?

Nothing will be faster than a simple loop. You can mix-and-match some array functions to do it, but they’ll just be implemented as a loop too. function whatever($array, $key, $val) { foreach ($array as $item) if (isset($item[$key]) && $item[$key] == $val) return true; return false; }

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

Nothing will be faster than a simple loop. You can mix-and-match some array functions to do it, but they’ll just be implemented as a loop too. function whatever($array, $key, $val) { foreach ($array as $item) if (isset($item[$key]) && $item[$key] == $val) return true; return false; }

Restructure multidimensional array of column data into multidimensional array of row data [duplicate]

As Kris Roofe stated in his deleted answer, array_column is indeed a more elegant way. Just be sure to put it into some kind of a foreach loop, similar to what Sahil Gulati showed you. For example, like this: $result = array(); foreach($where[‘id’] as $k => $v) { $result[] = array_column($where, $k); } The var_dump … Read more