I want to always keep three element in array. So, I want if new element is added in array then oldest element will remove from array and Re-index array. Which is the best and fast way to make it?
This is my first array
$foo = array(
'when', // [0]
'whom', // [1]
'what' // [2]
);
If new element "how" added, I want to modify like below.
$foo = array(
'how', // [0]
'whom', // [1]
'what' // [2]
);