jeudi 3 août 2017

Using loops to create shapes in PHP

I'm tasked with creating a shape in PHP using loops that is supposed to look like this: http://ift.tt/2vlsSua

I'm supposed to use nested loops and if statements.

My starting point is this piece of code:

<?php
$n = 5;

for ($i = 0; $i < $n; $i++) {
    $row = '';
    for ($j = 0; $j < $n; $j++) {
        $row .= '*';
    }
    echo $row . '<br>';
}
?>

I've been getting tips from my mentor but I still don't really know how to proceed.

Aucun commentaire:

Enregistrer un commentaire