PHP 8 Intermediate Basics · 1 min read

Multidimensional arrays

Start the PHP 8 learning path »

❮ PHP 8 Home All Tutorials ❯

How do I store rows of data?

Arrays of arrays.

Example

PHP 8 Example
<?php
$students = [
  ['name' => 'Ada', 'score' => 95],
  ['name' => 'Alan', 'score' => 88],
];
echo $students[0]['name'];

Line-by-Line Walkthrough

Common shape when fetching multiple DB rows.

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share

Reactions

Loading reactions…