PHP Code:
$varNum=1;
while($varNum<=9) {
$varNum1=1;
for($varSpace=1;$varSpace<=20-$varNum;$varSpace++) {
echo ' '; //if you are running this on browser replace this blank space with
}
while($varNum1<=$varNum) {
// if you want to creat piramid with character then replace the $varNum1 with desired character like '*' but only
// single character to be use
echo $varNum1.' ';//if you are running this on browser replace this blank space with
// echo '& ';//if you are running this on browser replace this blank space with
$varNum1++;
}
echo "\n"; // replace \n with <br> if using browser for output
$varNum++;
}
output:
Code:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6