method minWithKey documentation in bbn\X

Returns the minimum value of an index from a multidimensional array.

Example

X::minWithKey([ ['age' => 1, 'name' => 'Michelle'], ['age' => 8, 'name' => 'John'], ['age' => 45, 'name' => 'Sarah'], ['age' => 45, 'name' => 'Camilla'], ['age' => 2, 'name' => 'Allison'] ], 'age'); // int 1 function(array $array, $key) { if (\count($array) == 0) { return null; } $min = $array[0][$key] ?? null; if (!$min) { return null; } foreach($array as $a) { if($a[$key] < $min) { $min = $a[$key]; } } return $min; }

Returns the minimum value of an index from a multidimensional array. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.