插入有序的php数组,移动值

I have numbered array like

[0] => value 0
[1] => value 1
[2] => value 2
[3] => value 3
[4] => value 4
//keys 5-8 aren't set (I'm only demonstrating there could be a gap)
[9] => value 5
[10] => value 6

Is there any way to shuffle the array to move values when I add new to the specific position? So if i do something simillar to $array[1] = 'new value' it will change original value of 1 to new value of 2, 2 to 3 etc. up to 4 (then there is empty place in the example)?

Like this:

[0] => value 0
[1] => new value
[2] => value 1
[3] => value 2
[4] => value 3
[5] => value 4
[9] => value 5
[10] => value 6

Thank you very much for your help

Use array_splice .. Keep linear, not associated array, but places in array that need to be empty (for now) assign to null

Should work.

You could use the array_slice(). Check the examples below:

http://php.net/manual/en/function.array-splice.php