PHP:Accessing an Array

From Progzoo
Jump to navigation Jump to search

You access an array using the square bracket notation.

The first element of array $x is $x[0]


[Font] [Default] [Show] [Resize] [History] [Profile]

The last element of array $x is $x[count($x)-1]


[Font] [Default] [Show] [Resize] [History] [Profile]

Out of Bounds

If you try to read past the end of an array it returns NULL, and raises an error (which may or may not be ignored) of Undefined index.


[Font] [Default] [Show] [Resize] [History] [Profile]