Search for highest key/index in an array

Solution 1:

This should work fine

$arr = array( 1 => "A", 10 => "B", 5 => "C" );
max(array_keys($arr));

Solution 2:

You can get the maximum key this way:

<?php
$arr = array("a"=>"test", "b"=>"ztest");
$max = max(array_keys($arr));
?>