×

php · level 1 · unit 6 · lesson 1

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

An keeps many values together in one box.

So far each box has held one value. An array holds many values in one box, in order, like a shopping list. Each value in it is an .

Make one with square brackets and commas between the items: ["bread", "milk", "eggs"]. count tells you how many items an array holds.

echo cannot show a whole array. It stops with Array to string conversion. Instead, will glue the items into one string, with a comma and a space between each.

<?php
$shopping = ["bread", "milk", "eggs"];
echo count($shopping) . " things to buy\n";
echo implode(", ", $shopping) . "\n";

An array can hold numbers too, like [7, 9, 4], or no items at all, [].