note 105992 deleted from function.min by danbrown
| From: | danbrown@php.net | Date: | Fri, 30 Sep 2011 21:26:01 +0000 |
| Subject: | note 105992 deleted from function.min by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-183554@lists.php.net to get a copy of this message | ||
Note Submitter: hava82 at gmail dot com
----
***2 ADMIN if you see that please replace my previous post with this function
Improved version for min by key
function min_by_key($arr, $key){
$min = array();
foreach ($arr as $val) {
if (!isset($val[$key]) and is_array($val)) {
$min2 = min_by_key($val, $key);
$min[$min2] = 1;
} elseif (!isset($val[$key]) and !is_array($val)) {
return false;
} elseif (isset($val[$key])) {
$min[$val[$key]] = 1;
}
}
return min( array_keys($min) );
}