foreach works with a copy of $item , so you cannot modify your original array inside the foreach . One way to ...
stackoverflow.com