ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Arrays in PHP: Part 2
Subject:   How to Append indexed multiple data into existing arrays?
Date:   2004-08-24 12:49:12
From:   jeanloui
Hi,
I have this simple array:

Array
(
[central] => Array
(
[0] => jeanloui
)


[tusted] => Array
(
[0] => katia
[1] => felipe
[2] => veit
)
)


---------------


And I would like to append new nested indexed with multiple data into the same array, but into a new index as:


[new_index] => Array
(
[0] => pepito
[1] => lolita
[2] => juanito
)

---------------


If I write (after the array creation) for append:



$fruits["new_index"][] = "pepito";


...it gives me only:



Array
(
[central] => Array
(
[0] => jeanloui
)


[tusted] => Array
(
[0] => katia
[1] => felipe
[2] => veit
)


[new_index] => Array
(
[0] => pepito
)
)


.... adding the new index but ONLY ONE value: [0] => "pepito" into the new array index....


But I need the multiple data [0], [1], [2], etc. into new_index insertion...!


What is the syntaxis for appending new indexes with multiple data into arrays?


Thanks!