PHP 8.5.0 Alpha 4 available for testing

Voting

: max(four, nine)?
(Example: nine)

The Note You're Voting On

jasper at jtey dot com
19 years ago
This function returns the value at the end of the array, but you may sometimes be interested in the key at the end of the array, particularly when working with non integer indexed arrays:

<?php
// Returns the key at the end of the array
function endKey($array){
end($array);
return
key($array);
}
?>

Usage example:
<?php
$a
= array("one" => "apple", "two" => "orange", "three" => "pear");
echo
endKey($a); // will output "three"
?>

<< Back to user notes page

To Top