note 120949 deleted from function.array-search by cmb

From: Date: Sun, 01 Sep 2019 07:57:42 +0000
Subject: note 120949 deleted from function.array-search by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-212078@lists.php.net to get a copy of this message
Note Submitter: tammander at gmail dot com ---- /** * 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; }

« previous php.notes (#212078) next »