beetle
10-16-2002, 07:30 PM
I read through what feels like every array-related function in the PHP manual, but there doesn't seem to be an easy way to insert a value at a specified index, and push the rest foward.... $array = ("red","orange","green","blue","indigo","violet");
array_insert($array, "yellow", 2); // <-- what I would like...
// result for $array
Array
(
[0] = "red"
[1] = "orange"
[2] = "yellow"
[3] = "green"
[4] = "blue"
[5] = "indigo"
[6] = "violet"
)What gives? Did I read to much and scramble my brain, therefore missing it? Or do I need to create my own array_insert() type function??
array_insert($array, "yellow", 2); // <-- what I would like...
// result for $array
Array
(
[0] = "red"
[1] = "orange"
[2] = "yellow"
[3] = "green"
[4] = "blue"
[5] = "indigo"
[6] = "violet"
)What gives? Did I read to much and scramble my brain, therefore missing it? Or do I need to create my own array_insert() type function??