programming-examples/php/_Basics/Number Pattern Problems in PHP.php

59 lines
535 B
PHP
Raw Normal View History

2019-11-15 12:59:38 +01:00
/* Print number Pattern in PHP */
<?php
for($a=1; $a<=5; $a++)
{
for($b=$a; $b>=1; $b--)
{
echo "$b";
}
echo "<br>";
}
?>
/* Output
1
21
321
4321 */
/* Print number Pattern in PHP */
<?php
for($a=5; $a>=1; $a--)
{
for($b=1; $b<=$a; $b++)
{
echo $b;
}
echo "</br>";
}
?>
/* Output
12345
1234
123
12
1 */
/* Print number Pattern in PHP */
<?php
for($a=5; $a>=1; $a--)
{
for($b=5; $b>=$a; $b--)
{
echo $b;
}
echo "</br>";
}
?>
/* Output
5
54
543
5432
54321 */