Published on 2020-03-07 • Modified on 2020-03-07
This is the kind of thing that it's easy to do with PHP. We can use
splice() function is quite weird as it can delete items but also insert elements at the same time! Be very careful when using it. Note that the array is mutated and keys are reordered. I have done the same examples with Lodash; they are much straightforward.