note 89449 added to function.in-array
| From: | brouwer dot p at gmail dot com | Date: | Sun, 08 Mar 2009 10:55:12 +0000 |
| Subject: | note 89449 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-151625@lists.php.net to get a copy of this message | ||
If made a in_array function that checks if the specified key matches. It works recursivly so it
doesn't matter how deep your input array is.
<?php
function myInArray($array, $value, $key){
//loop through the array
foreach ($array as $val) {
//if $val is an array cal myInArray again with $val as array input
if(is_array($val)){
if(myInArray($val,$value,$key))
return true;
}
//else check if the given key has $value as value
else{
if($array[$key]==$value)
return true;
}
}
return false;
}
?>
----
Server IP: 213.249.64.162
Probable Submitter: 80.101.12.17
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/89449
Del: integrated -- https://master.php.net/note/delete/89449/integrated
Del: useless -- https://master.php.net/note/delete/89449/useless
Del: bad code -- https://master.php.net/note/delete/89449/bad+code
Del: spam -- https://master.php.net/note/delete/89449/spam
Del: non-english -- https://master.php.net/note/delete/89449/non-english
Del: in docs -- https://master.php.net/note/delete/89449/in+docs
Del: other reasons-- https://master.php.net/note/delete/89449
Reject -- https://master.php.net/note/reject/89449
Search -- https://master.php.net/manage/user-notes.php