quick links

Print all type pattern

Below are the diffrent pattern like star, 123 etc...

<?php
for($i=1; $i<=5; $i++) {
for($j=$i; $j<=5; $j++) {
echo " ";
}
for($k=1; $k<=$i; $k++) {
echo "*";echo " ";
}
echo "
";
}
?>

OUTPUT: *
* *
* * *
* * * *
* * * * *

 

<?php
for($i=1; $i<=5; $i++) {
for($k=1; $k<=$i; $k++) {
echo "*";echo " ";
}
echo "
";
}
?>

OUTPUT: *
* *
* * *
* * * *
* * * * *

 

<?php
for($i=1;$i<=5;$i++)
{
for($j=1;$j<=$i;$j++)
{
echo $j;
}
echo '
';
}
?>

OUTPUT: 1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

 

<?php
for($i=1;$i<=5;$i++)
{
for($j=1;$j<=$i;$j++)
{
echo $i;
}
echo '
';
}
?>

OUTPUT: 1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

 

About Us

Joomla Web Solution

We love working with PHP, HTML5, CSS3, jQuery and the most-loved content management framework in the world, Joomla!

LIKE US ON FACEBOOK