Posts

Showing posts from December, 2014

Draw pyramid shape of stars in PHP using loop structure Write down the code in PHP using loop structure to draw the 3 pyramid shapes of stars as given bellow:

Image
ravimanephpmysql // problem 01 solution for($i=5;$i>=1;$i--) { echo  str_repeat('*',$i); echo "<br />"; } echo "<hr />"; // problem 02 solution for($i=1;$i<=5;$i++) { echo  str_repeat('*',$i); echo "<br />"; } echo "<hr />"; // problem 03 solution $j=1; for($i=5;$i>=1;$i--) { //echo  str_repeat("&nbsp;",$i-1); echo  str_repeat('*',$j++); echo "<br />"; }