Dereferencing

Dereferencing is the action to access a value, which is referenced with a pointer. Since PHP has no pointer, dereferencing applies to accessing an element in an array or an object.

Dereferencing is also possible to function and methods calls: when a function returns an array or an object, it is possible to immediately access one of the element by using the array or method syntax.

<?php

$array = ['a', 'b', 'c'];

echo $array['b'];

function foo() {
    return ['x', 'y', 'z'];
}

// Function Array Dereferencing
foo()[2]; // display z

?>

Documentation

See also Function Array Dereferencing (FAD), Array Dereferencing in PHP and Function Array Dereferencing in PHP (example 8).

Related : Functions, Array, Object, Function Subscripting