PHP Arrays (Indexed) Example

Create, read, add to and count indexed arrays in PHP. Edit the code below and press Run to execute it with real PHP in your browser.

Code Editor
Output
First: 10
Last: 50
Count: 5
Now: 0, 10, 20, 30, 40, 50, 60
Popped: 60

How this arrays (indexed) example works

Indexed arrays use integer keys starting at 0. $array[] = $value appends, array_unshift() prepends, array_pop() removes the last element and count() returns the number of elements.