How can I create a pyramid from using php?
<p>I need to create a pyramid using asterisks. I specify a value which becomes the base of the pyramid. The base contains as much asterisks as the value specified and the pyramid must skip its rows by 1..Here I am facing a problem when I specify an even number of base..</p>

<p>The pyramid must looke like the one below.</p>

<pre><code>    * 
   *** 
  ***** 
 ******* 
********* 
********** 
</code></pre>

<p>I am getting </p>

<pre><code>####* 
###*** 
##***** 
###***** 
####***** 
********** 
</code></pre>

<p>I want to replace the # by some blank space and I am getting the bug that the number of asterisks in the 4th row has decreased.. How do I fix these two bugs ?</p>

<pre><code>function create_pyramid($limit){

     if ($limit &gt; 0){
        for ($row =0;$row&lt;=$limit;$row++){
            if (($row % 2 == 0) &amp;&amp; ($row != $limit)){ continue;}
            $rows = "";
            for ($col =0;$col&lt;$row;$col++){
                $rows= $rows.'*';
            }
            $pattern = "%'#".((($limit - $row)/2)+$row)."s\n";
            printf ($pattern,$rows);
            print '&lt;br /&gt;';
        }
        }
        else{
            print "Invalid data";
        }
     }

     create_pyramid(10);
</code></pre>
