Home >> PHP >> How to print half pyramid using one to ten number in PHP

How to print half pyramid using one to ten number in PHP

$num=1;

$rows=4;

for($i=1;$i<=$rows;$i++){

      for($j=1;$j<=$i;$j++){

               echo $num;

               $num++;

      }

     echo "\n";

}

Output

1

2        3

4        5         6

7        8         9        10

Post Your Comment

Next Questions
How to print pyramid pattern using star
How to print half pyramid pattern using star
How to print half pyramid pattern using star after 180 degree rotation
display errors
string to array
array to string
how to split string into array
How to convert array to string
Difference between exit and die
Set Cookie
Access Cookie
Remove Cookie
how to remove \r\n from string
how to remove new lines from string
how to remove nbsp from string
How to remove all whitespace from a string
How to convert array to string separated by comma
How to list last 12 months from current month
Get the last 12 months from current month
How to list last 6 months from current month
Get the last 6 months from current month
How to list last 12 months from current month by loop
Get the last 12 months from current month by loop
How to list last 6 months from current month by loop
Get the last 6 months from current month by loop

Copyright ©2022 coderraj.com. All Rights Reserved.