Advertisement
cdsatrian

piramid star

Jul 9th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <pre>
  2. <?php
  3. //rata kiri
  4. $bil=isset($_GET['b'])?$_GET['b']:6;
  5. for($i=0;$i<=$bil;$i++){
  6.   for($j=0;$j<$i;$j++){
  7.     echo "* ";
  8.   }
  9.   echo "\n";
  10. }
  11. //rata tengah
  12. for($i=0;$i<=$bil;$i++){
  13.   $o="";
  14.   for($j=0;$j<$i;$j++){
  15.     $o.="* ";
  16.   }
  17.   echo str_pad($o,2*$bil," ",STR_PAD_BOTH)."\n";
  18. }
  19. //rata kanan
  20. for($i=0;$i<=$bil;$i++){
  21.   $o="";
  22.   for($j=0;$j<$i;$j++){
  23.     $o.="* ";
  24.   }
  25.   echo str_pad($o,2*$bil," ",STR_PAD_LEFT)."\n";
  26. }
  27. ?>
  28. </pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement