I have been looking and thinking, but can't come up with a viable solution to this problem.
I have an array with sequencial numerical keys
Example:
Array
(
[0] => value 0
[1] => value 1
[2] => value 2
[3] => value 3
)
I need to add a new key/value pair in between two specific keys in my array.
Example:
I need to add [a] => value a between keys 1 and 2 like
Array
(
[0] => value 0
[1] => value 1
[a] => value a
[2] => value 2
[3] => value 3
)
What I already though of doing, but seems the long way around
slicing my array in two, add my key/value pair to the back of slice one, and recombine my 2 slices into a single array
somehow advancing each key by one after key
1modifying my new key/value pair to[2] => value a, the add it to the back of the array, and then resort my array
Any suggestions to a quick clean way to achieve this