Example 1 — Get the Last Value
Read the final item of a list.
<?php
$colors = ["red", "green", "blue"];
echo array_last($colors), PHP_EOL; How It Works
- Create a list. The last item is
blue. - Call array_last(). It returns the value at the end.
- Print it. The output is
blue. - The array is not changed. Nothing is removed, unlike
array_pop().

