Re: Array
..oO(Damodhar)
>no need to add end of the array i want to add inter mediate the array
>exactly given position .
PHP arrays don't have a fixed order. You add new elements to the
beginning or end of the array and then sort it the way you want.
Given your example array:
Array
(
[1] => one
[2] => two
[3] => three
[5] => five
[6] => six
)
Add a new element with the key 4:
$name[4] = 'four';
Array
(
[1] => one
[2] => two
[3] => three
[5] => five
[6] => six
[4] => four
)
Then sort the array:
ksort($name);
Array
(
[1] => one
[2] => two
[3] => three
[4] => four
[5] => five
[6] => six
)
HTH
Micha
|