Mar 16, 2008

Get Maximum Value from string Key PHP Array

Thanks for visiting.


Tyron said...

There is a trick you can do...

Considering $array1 as the array which you wish the maximum key value, you can do:

$array_max = array_keys($array1);
$key_max = max($array_max);

Just remembering: array_keys returns all the keys from the specified array in a new array. And the function max returns the maximum value of the array.
Hope it helped.

Privacy Policies