A simple Queue data structure mechanism which allows you to set a max limit of items you wish to hold. After the max amount is met any subsequent additions will knock off items from the end.
include 'vendor/autoload.php';
use vbpupil\Queue\Queue;
// create a new queue and specify a limit - here we have set it to hold 1 item.
$q = new Queue(1);
//add items
$q->addItem('Item 1')
->addItem('Item 2')
->addItem('Item 3')
->addItem('Item 4')
->addItem('Item 5');
echo($q->getItems());
The above example will return 1 item with the value of Item 5.