105 of 110 menu

PHP Two-Dimensional Array

A two-dimensional array is an array whose elements are also arrays. See an example:

<?php $arr = [ 'boys' => ['John', 'Nick', 'Alex'], 'girls' => ['Mary', 'Helen', 'Jane'], ]; echo $arr['boys'][0]; ?>

Let's output, for example, 'Nick' using our array:

<?php $arr = [ 'boys' => ['John', 'Nick', 'Alex'], 'girls' => ['Mary', 'Helen', 'Jane'], ]; echo $arr['boys'][1]; // will output 'Nick' ?>

And now let's output 'Jane':

<?php $arr = [ 'boys' => ['John', 'Nick', 'Alex'], 'girls' => ['Mary', 'Helen', 'Jane'], ]; echo $arr['girls'][2]; // will output 'Jane' ?>
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