like
array(a, b, c, d, e);
I want to add new elements to it, but keep the maximum element count to 5. So if after the add the count exceeds 5, I want to remove elements from the start until the size of the array is 5 again.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Add elements in array and check following condition
if(count($arr) >= 5) { array_shift($arr); //remove element from beginning }