I am stuck here. I have this loop with if else condition, and I need else output in one iteration to change based on the output of the previous iteration. Here is the example:
$mr1 = 2;
$mc1 = 4;
$mr2 = 2;
$mc2 = 3;
$r = 5; $c = 5;
echo "<table>";
for ($i=1; $i <= $r; $i++) {
echo "<tr>";
for ($n=1; $n <= $c; $n++) {
if ((($i == $mr1) AND ($n == $mc1)) || (($i == $mr2) AND ($n == $mc2))){
echo "<td> * </td>";
} else
echo "<td> 1 </td>";
}
echo "</tr><br>";
}
echo "</table><br><hr/><br>";
So in this loop if the condition is met output will be a *
otherwise it will be number 1
. What I don't know how to achieve is to make the code to output 2
if in previous iteration output was *
.
I hope you understand what I want to say?
Thanx