Umair Y.
asked 08/07/15PHP Loop Help
1 Expert Answer

Stefan R. answered 03/10/20
Senior PHP developer with 10+ years of experience
The code:
Explanation:
A for loop has three commands. The first one is assigning a value to the iterator ($i = 1). The second is the condition. Here we declare that the iteration shall proceed as long as the condition of $i being smaller or equal to 100 is met ($i <= 100). The last command describes what the iterator should do after gong through the block. In our case, we increment ($i++) the iterator. Incrementing with "++" is the same as if you were to write "$i = $i +1"
In our code we use the iterator ($i) directly as output to represent the current value.
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Anthony F.
<body>
<?php
for ($x=1; $x<=100; $x++)
{
echo "Number is " . $x . "<br />";
}
?>
</body>
</html>
Number is 2
Number is 3
Number is 4
Number is 5
11/04/15