Skip to content

Instantly share code, notes, and snippets.

@andrijeski
Created January 15, 2013 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrijeski/4542806 to your computer and use it in GitHub Desktop.
Save andrijeski/4542806 to your computer and use it in GitHub Desktop.
C:\Users\Sasho>howdoi php check value in an array
Nothing will be faster than a simple loop. You can mix-and-match some array functions to do it, but they'll ju
st 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;
}
http://stackoverflow.com/questions/6990855/php-check-if-value-and-key-exist-in-multidimensional-array (1/5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment