Showing posts with label star. Show all posts
Showing posts with label star. Show all posts

Tuesday, 21 May 2013

How to implement reverse Star pattern in php

In interview, interviewer asked me to write program for reverse star pattern. it was just to check my logic. in this post I am sharing this program.

Inner loop prints line wise and outer loop prints column wise.

<?php
           for($i = 10; $i > 0 ; $i--){
                  for($j = 0; $j < $i ; $j++){
                         echo '*';
                  }
                  echo '<br/>';
            }
?>

Output of the above code will be
**********
*********
********
*******
******
*****
****
***
**
*