How to get the last element of an PHP array

$lastValue = array_values(array_slice($spread, -1))[0];

Reference:

https://stackoverflow.com/questions/3687358/whats-the-best-way-to-get-the-last-element-of-an-array-without-deleting-it

Tags

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top