note 120949 added to function.array-search
| From: | tammander at gmail dot com | Date: | Thu, 06 Apr 2017 16:45:31 +0000 |
| Subject: | note 120949 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-208993@lists.php.net to get a copy of this message | ||
/**
* Search into multidimensional array all ocurrences of $needle
*
* @param String $needle value to find
* @param Array $arr multidimensional array where find
*
* @return Array empty array or array of parent keys where found
*
*/
function search_value_in($needle, $arr)
{
$result = [];
$found = 0;
if (is_array($arr)) {
foreach ($arr as $in) {
if (is_array($in)) {
if (array_search($needle, $in) !== false) {
$result[] = $found;
}
}
$found++;
}
}
return $result;
}
----
Server IP: 72.52.91.14
Probable Submitter: 85.57.58.41
----
Manual Page -- http://php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/120949
Del: integrated -- https://master.php.net/note/delete/120949/integrated
Del: useless -- https://master.php.net/note/delete/120949/useless
Del: bad code -- https://master.php.net/note/delete/120949/bad+code
Del: spam -- https://master.php.net/note/delete/120949/spam
Del: non-english -- https://master.php.net/note/delete/120949/non-english
Del: in docs -- https://master.php.net/note/delete/120949/in+docs
Del: other reasons-- https://master.php.net/note/delete/120949
Reject -- https://master.php.net/note/reject/120949
Search -- https://master.php.net/manage/user-notes.php