68 of 110 menu

PHP Key of the First Array Element

Since programming uses zero-based numbering, the key of the first array element is 0. See the example:

<?php $arr = ['a', 'b', 'c']; echo $arr[0]; ?>

Code execution result:

1

To output the first element of an array, use the function array_shift. See the example:

<?php $arr = ['a', 'b', 'c']; echo array_shift($arr); ?>

Code execution result:

'a'
English
БеларускаяEspañolРусский
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline