Is there any function to query the array in PHP?
PHP in_array() (http://www.php.net/manual/en/function.in-array.php), , - , array_search() (http://www.php.net/manual/en/function.array-search.php), in_array(), .
mysql_query(), - :
function array_query($array,$what){
if(in_array($what, $array)){
return $array[array_search($what, $array)];
}
return false;
}
,
EDIT: array_search() ( ), , array_search($what, $array) recursiveArraySearch($array,$what):
function recursiveArraySearch($haystack, $needle, $index = null)
{
$aIt = new RecursiveArrayIterator($haystack);
$it = new RecursiveIteratorIterator($aIt);
while($it->valid())
{
if (((isset($index) AND ($it->key() == $index)) OR (!isset($index))) AND ($it->current() == $needle)) {
return $aIt->key();
}
$it->next();
}
return false;
}