Skip to content
Advertisement

PHP: What is the fastest and easiest way to get the last item of an array?

What is the fastest and easiest way to get the last item of an array whether be indexed array , associative array or multi-dimensional array?

Advertisement

Answer

$myArray = array( 5, 4, 3, 2, 1 );

echo end($myArray);

prints “1”

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement