lundi 20 février 2017

I want to print triangle in stars pattern in PHP can anyone help, Just using two for loops only to solve it?

Please give me the solution for to print a triangle in stars pattern using php language. I used only 2 for loops to finish this.

   *
  ***
 *****
*******

Here is my code

<?php
for($a=1;$a<=7;$a++)
{
    for($b=1;$b<=$a;$b++)
    {
        echo " *";
    }
    echo "<br/>";
}
echo " ";
?>

Please help me out.




Aucun commentaire:

Enregistrer un commentaire