php - Hightest value of an associative array -
is there easy way hightest numeric value of associative array?
$array = array( 0 => array( 'key1' => '123', 'key2' => 'values we', 'key3' => 'do not', 'key4' => 'care about' ), 1 => array( 'key1' => '124', 'key2' => 'values we', 'key3' => 'do not', 'key4' => 'care about' ), 2 => array( 'key1' => '125', 'key2' => 'values we', 'key3' => 'do not', 'key4' => 'care about' ) ); awesomefunction($array, 'key1'); // returns 2 ($array key)
please kind since question written phone. thanks.
if know data in format, should work.
function getmax( $array ) { $max = 0; foreach( $array $k => $v ) { $max = max( array( $max, $v['key1'] ) ); } return $max; }
Comments
Post a Comment