0. What we start with

$numbers:

Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
)

1. Array Shifting

array_shift shifts the first element out of an array and returns the value.

$a = array_shift($numbers)
returns: 1

$numbers after array_shift:

Array
(
    [0] => 2
    [1] => 3
    [2] => 4
    [3] => 5
    [4] => 6
)

2. Array Unshifting

array_unshift prepends an element to an array and returns the element count.

$b = array_unshift($numbers, 'first')
returns: 6

$numbers after array_unshift:

Array
(
    [0] => first
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => 6
)


3. Array Pop

array_pop pops the last element out of an array and returns the value.

$a = array_pop($numbers)
returns: 6

$numbers after array_pop

Array
(
    [0] => first
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
)

4. Array Push

array_push pushes an element onto the end of an array and returns the element count.

$b = array_push($numbers, 'last')
returns: 6

$numbers after array_pop

Array
(
    [0] => first
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
    [5] => last
)