Daan Smits Daan Smits - 28 days ago 6
PHP Question

PHP Loop exercise (help QQ)

PHP exercise

enter image description here

Hi, I have no idea how to solve this above exercise, I tried a lot but i have no idea. I need the help of the overflow people, help me.

for ($x = 10; $x > 1; $x--)
{
$t=10;
$y = 0;
while($t<10){
$t--;
$y++;
}
$t--;
while ($y < $x)
{
echo "$y";
$y++;
}


for ($d = 10; $d > $x; $d--)
{
echo "$d";
}

echo "<br>";
}


this is how far i got. :3 tried a lot still do not know.

Answer

Not so complicated col + row modulo 10

<?php

for ($i=0;$i<10;++$i) {
    for ($j=0;$j<10;++$j) {
        echo ($j+$i) % 10,' ';
    }
    echo "\n";
}
Comments