S
Seoffix.com
Sign In Get Pro Membership

PHP 8 Server-Side

PHP Arrays and Loops

Beginner PHP 25 XP

PHP Arrays and Loops

foreach walks every item of an array.

Example

<?php
$tags = ["seo", "ai"];
foreach ($tags as $tag) {
    echo $tag . "\n";
}

Your task

Loop over $colors and echo each colour followed by a new line.

Hints

  1. foreach ($colors as $color)
  2. Echo inside the loop

Check your understanding

Answer every question to pass.
1. Which loop is made for arrays in PHP?

Your answer

This lesson is checked against the lesson rules. Your code is never run on our servers.

AI Code Explainer & Translator

Runs without any outside service.
 
Mark Complete & Earn XP
Earn 25 XP after you pass the quiz. Finish every lesson in the track to earn its certificate.
Sign in to earn XP