Skip to content
Quiz · Loops · lesson 5 of 6

Quiz — foreach copies the element

What does the program print?

PHP
<?php

$prices = [10, 20, 30];
$total = 0;
foreach ($prices as $price) {
    $price = $price * 2;
    $total += $price;
}
echo $total, ' ', $prices[0], ' ', count($prices), "\n";