How to write a program in PHP to generate a star triangle pattern?

PHP program to generate a triangle symbol with stars.

 

Please get the below PHP code to generate the above star symbol.

 

for($r=1;$r<=5;$r++)

{

 for($s=1;$s<=$r;$s++)

    {

     echo " ";

    }

 for($st=5;$st>=$r;$st--)

    {

     echo "* ";

    }

 echo "
";

}

 

for($r=2;$r<=5;$r++)

{

 for($st=5;$st>=$r;$st--)

    {

     echo " ";

    }

 for($s=1;$s<=$r;$s++)

    {

     echo "* ";

    }

 echo "
";

}