50. PHP Program to Display 1 to 99 numbers in 5 Columns Sequentially.
How does this program work?
- In this program we are going to learn about how to display 1to 99 numbers in 5 columns sequentially using PHP.
- In this program we are using two loops, while and for loop to display 100 numbers in given format.
Here is the code
<html>
<head>
<title>PHP Program To display 1 to 99 numbers in 5 columns sequentially</title>
</head>
<body>
<?php
$a = 5;
$j = 1;
$x = 0;
echo ("Numbers from 1 to 100: ");
// To print numbers from 1 to 100
for($i = 1; $i <= $a; $i++)
{
while( $x < 20)
{
echo " ".$j++; //To printing the numbers
$x++; //Increasing loop counter by 1
}
$x = 0;
echo " ";
}
return 0;
?>
</body>
</html>