PHP 8 Beginner Basics · 1 min read

Indexed arrays

Start the PHP 8 learning path »

❮ PHP 8 Home All Tutorials ❯

How do I store a list in PHP?

Numeric indexes from 0.

Example

PHP 8 Example
<?php
$colors = ['red', 'green', 'blue'];
echo $colors[0];
$colors[] = 'yellow';

Line-by-Line Walkthrough

Appending with $arr[] pushes to the end.

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share

Reactions

Loading reactions…