Array Examples

Populate (fill) an index array with numbers

Array ( [0] => 10 [1] => 11 [2] => 12 [3] => 13 [4] => 14 [5] => 15 [6] => 16 [7] => 17 [8] => 18 [9] => 19 [10] => kayjay [11] => 4 [12] => 1.5 [13] => 22 )
Array
(
    [0] => 10
    [1] => 11
    [2] => 12
    [3] => 13
    [4] => 14
    [5] => 15
    [6] => 16
    [7] => 17
    [8] => 18
    [9] => 19
    [10] => kayjay
    [11] => 4
    [12] => 1.5
    [13] => 22
)

Populate an index array with the Months of the Year

Array
(
    [0] => Jan
    [1] => Feb
    [2] => Mar
    [3] => Apr
    [4] => May
    [5] => Jun
    [6] => Jul
    [7] => Aug
    [8] => Sep
    [9] => Oct
    [10] => Nov
    [11] => Dec
)

Populate an associative array with Population Data for the United States

Array
(
    [name] => USA
    [population] => 333.3 million
    [average age] => 38.5 years
    [official language] => none
)

Populate a multidimensional associative array with Population Data for Other North American Countries

Array
(
    [0] => Array
        (
            [name] => Canada
            [population] => 38.93 million
            [average age] => 40.6 years
            [official language] => French, English
        )

    [1] => Array
        (
            [name] => Mexico
            [population] => 127.5 million
            [average age] => 29.3 years
            [official language] => Spanish, various indigenous languages
        )

    [2] => Array
        (
            [name] => Haiti
            [population] => 11.58 million
            [average age] => 23.8 years
            [official language] => Haitian Creole, French
        )

    [3] => Array
        (
            [name] => El Salvador
            [population] => 6.336 million
            [average age] => 27.4 years
            [official language] => Spanish
        )

)