49. PHP Program to Display 1 to 99 numbers in 5 Rows Sequentially.
How does this program work?
- In this program we are going to learn about how to display 1to 99 numbers in 5 rows sequentially using PHP.
- In this program we are using two loops, while and for loop to display numbers.
- While loop is used to print 100 numbers and to print 5 numbers on each line by using for loop.
Here is the code
<html>
<head>
<title>PHP Program To display 1 to 99 numbers in 5 rows sequentially</title>
</head>
<body>
<?php
$number = 1;
echo ("Numbers from 1 to 100: ");
//While loop, that will print numbers
//From 1 to 100
while($number <= 100)
{
//For loop to print 5 numbers in a line
for ( $i = 1;$i <= 5;$i++)
{
//To printing the numbers
echo " ".$number;
//Increasing loop counter by 1
$number++;
}
echo " ";
}
return 0;
?>
</body>
</html>