Whenever a certain event occurs, value x is added to the end of array myarray. Now this is fine for a while, but since I'm drawing the contents of my array, I need to limit its size to about 20 entires, the most recent ones.
So far, my code for adding an element, checking to see if it's over the 20 element limit and deleting the first element does not work:
$numbers[] = $latestnumber;
if (count($numbers) > 20)
{
$numbers= array_shift($numbers);
echo "Numbers Array Shifted.";
}
Whenever the condition is met, however, the array srinks to a size of one, rather than knocking one off. Can anyone see why and how to fix it?😕