programming-examples/php/Basics/Number Pattern Problems in PHP.php
2019-11-18 14:44:36 +01:00

59 lines
535 B
PHP

/* 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 */