Say I have this array:
$array[] = \'foo\'; $array[] = \'apple\'; $array[] = \'1234567890;
I want to get the length of the longest string in
Sure:
function getmax($array, $cur, $curmax) { return $cur >= count($array) ? $curmax : getmax($array, $cur + 1, strlen($array[$cur]) > strlen($array[$curmax]) ? $cur : $curmax); } $index_of_longest = getmax($my_array, 0, 0);
No loop there. ;-)