j0nas500

PHP Baum mit *

Dec 4th, 2020
438
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Version 1
  2. <?php
  3. $max = 7;
  4. for ($x = 0; $x <= $max; $x++) {
  5.   echo "&nbsp;<br>";
  6.   for ($y = $x; $max >= $y; $y++) {
  7.     echo "&nbsp;";
  8.   }
  9.  
  10.   for ($z = 0; $z <= $x; $z++) {
  11.     echo "*";
  12.   }
  13. }
  14. ?>
  15.  
  16. // Version 2
  17. <?php
  18. $max = 7;
  19.  
  20. for ($x = 0; $x <= $max; $x++) {
  21.   echo "&nbsp;<br>";
  22.  
  23.   for ($y = $x; $max >= $y; $y++) {
  24.     echo "&nbsp;&nbsp;";
  25.   }
  26.  
  27.   for ($z = 0; $z <= 1; $z++) {
  28.     echo "*";
  29.     for ($z = 1; $z <= $x; $z++) {
  30.     echo "**";
  31.     }
  32.   }
  33. }
  34. ?>
RAW Paste Data