Hello, I am 1 week into learning PHP and I like it, but am stumped.
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXX
I accomplished this with this:
[php]
for ($row = 1; $row <= 6; $row++)
{
for ($col = 1; $col <= 20; $col++)
{
echo ‘X’;
}
echo "<br>";
}[/php]
I have to make a pattern…so columns wide, and 6 rows high. I have that. Then next step we have to make is to make the following pattern…
XXXXXXXXXXXXXXXXXXX
X XXXXXXXXXXXXXXXXXX
XX XXXXXXXXXXXXXXXXX
XXX XXXXXXXXXXXXXXXX
XXXX XXXXXXXXXXXXXXX
XXXXX XXXXXXXXXXXXXX
I tried to accomplish this by the following:
[php]
for ($row = 1; $row <= 6; $row++)
{
for ($col = 1; $col <= 20; $col++)
if ($row == $col)
{
echo " ";
}
else
{
echo "X";
}
echo "<br>";
}
[/php]
The problem is the space is not being recognized and all my code is doing is making the “X”'s not line up.
Any suggestions for a coding rookie?