i’m trying to make cartesian coordinate for my coursework and can only get here, I’m grateful if anyone can help me to fix this "0" line
<?php
$n=10;
for($i=-10;$i<=$n;$i++){
for($j=-10;$j<=$n;$j++){
if($i==0 || $j==0){
echo " $i ";
} else {
echo " ";
}
}
echo "\n";
}
Current output
What i expected
>Solution :
You can try this in mode console.
But it’s not really readable
But the principle is there
$n=10;
for($y=$n;$y>-$n;$y--)
{
for($x=-$n;$x<=$n;$x++)
{
$infoDisplay = " ";
if($x==0) $infoDisplay = $y;
if($y==0) $infoDisplay = $x;
echo $infoDisplay;
}
echo "\n";
}