Discussion: Array Help
Afficher un message
Vieux 25/03/2008, 20h34   #4
Michael Fesser
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
  Réponse avec citation
 
Page generated in 0,04637 seconds with 9 queries