ESHAN
Please Help Any Helpless Person
01 May, 2010
Check If A Value Exists In Associative Array
The "
in_array
" function of php checks if a value exists in an array. But it don't work properly with associative array. Here is a function which will work properly with associative array.
function in_assoc($needle,$array)
{
$key = array_keys($array);
$value = array_values($array);
if (in_array($needle,$key)){return true;}
elseif (in_array($needle,$value)){return true;}
else {return false;}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment