Voting

: max(three, seven)?
(Example: nine)

The Note You're Voting On

rnealxp at yahoo dot com
5 years ago
Now that we have this function, where we once used...
<?php
$idxLast
= count($arr) - 1;
?>
we can now optimize code speed by using...
<?php
$idxLast
= (array_key_last($arr) ?? 0);
?>
Use-cases include lots of looping and control-structures.
If you do not know ahead of time that the array is numerically indexed, and that it could possibly be associative...safer/faster to stick with count().

<< Back to user notes page

To Top