faqts : Computers : Programming : Languages : PHP : kms : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

28 of 31 people (90%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How do I append a new item to an array?
How can I add new items to the end of an array?

Sep 17th, 1999 01:14
Nathan Wallace, Richard Lynch


If you have an array in PHP:

    $a = array('a', 'b', 'c');

you can add new items to the end like this:

    $a[] = 'd';
    $a[] = 'e';

in PHP 4 you can use:

array_push($a, 'd', 'e')

to append any number of elements to the array.