Is there a PHP v5.5 equilavent to max for lodash/underscore?
Basically I would like to be able to do something similar to this:
$characters = [
{ 'name': 'barney', 'age': 36 },
{ 'name': 'fred', 'age': 40 }
];
max($characters, 'age');
// → { 'name': 'fred', 'age': 40 };
There is a port of Underscore called Underscore.php which provides the max function (as well as many other Underscore functions).
From its documentation:
$stooges = array(
array('name'=>'moe', 'age'=>40),
array('name'=>'larry', 'age'=>50),
array('name'=>'curly', 'age'=>60)
);
__::max($stooges, function($stooge) { return $stooge['age']; });
// array('name'=>'curly', 'age'=>60)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With