Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Index For Arrays

A index, also called a key, is the identifier of an specific element in an array. They may automatically generated, by simply omitting them at creation time.

PHP index may be integers or strings only. Other data types generate an error or a type conversion. For example, floats are turned into integer. integer-shaped strings will also be turned into integer.

PHP index start at 0. They may be automatically assigned by appending a new value with the [] operator: then, they use the greatest available index + 1.

<?php

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

    echo $array[0];

?>

Documentation

See Also