Pyramid program in PHP
Hello All,
This is kind of fun stuff.
I was bored and decided to build a Pyramid Program in PHP.
<?php
$max = 5; //any numeric value to be assigned here
for($i=1;$i<=$max;$i++)
{
inter($i,$max);
}
for($i=$max-1;$i>=1;$i--)
{
inter($i,$max);
}
function sp($j,$max)
{
for($i=$j;$i<$max;$i++)
{
echo ' ';
}
}
function inter($i,$max)
{
$j=1;
sp($i,$max);
while ($j<=$i)
{
echo ' '.$j;
if($j==$i)
{
$m = $j-1;
while ($m>=1)
{
echo ' '.$m;
$m--;
}
}
$j++;
}
echo '<br/>';
}
?>
Above code on execution will output

Enjoy 🙂
3 thoughts on “Pyramid program in PHP”
Comments are closed.

hi
dear
very good
now i want script code about html pagination export in ms word
best regards
Mohammad
Do you want script for HTML pagination?
yes