Skip to main content
bytes--
Source Link
lll
  • 261
  • 1
  • 8

PHP - 7875

<?=($p='          ').'*
';for($s=' 0';$p=substr($p,1);;$s.='00'){echo"$p$s
";$s.='00';}";

For variable heights of 12 or below, modify the hard-coded padding in the above. (Code gets smaller the lower the height)

For variable heights of 13 or more use the following, height param is the second argument to str_pad. (Code starts at 8077 bytes and doesn't grow as fast as the version with static padding)

<?=($p=str_pad('',13)).'*
';for($s=' 0';$p=substr($p,1);;$s.='00'){echo"$p$s
";$s.='00';}";

Output of php -d short_open_tag=1 tree.php

          *
          0
         000
        00000
       0000000
      000000000
     00000000000
    0000000000000
   000000000000000
  00000000000000000

PHP - 78

<?=($p='          ').'*
';for($s=' 0';$p=substr($p,1);){echo"$p$s
";$s.='00';}

For variable heights of 12 or below, modify the hard-coded padding in the above. (Code gets smaller the lower the height)

For variable heights of 13 or more use the following, height param is the second argument to str_pad. (Code starts at 80 bytes and doesn't grow as fast as the version with static padding)

<?=($p=str_pad('',13)).'*
';for($s=' 0';$p=substr($p,1);){echo"$p$s
";$s.='00';}

Output of php -d short_open_tag=1 tree.php

          *
          0
         000
        00000
       0000000
      000000000
     00000000000
    0000000000000
   000000000000000
  00000000000000000

PHP - 75

<?=($p='          ').'*
';for($s=' 0';$p=substr($p,1);$s.='00')echo"$p$s
";

For variable heights of 12 or below, modify the hard-coded padding in the above. (Code gets smaller the lower the height)

For variable heights of 13 or more use the following, height param is the second argument to str_pad. (Code starts at 77 bytes and doesn't grow as fast as the version with static padding)

<?=($p=str_pad('',13)).'*
';for($s=' 0';$p=substr($p,1);$s.='00')echo"$p$s
";

Output of php -d short_open_tag=1 tree.php

          *
          0
         000
        00000
       0000000
      000000000
     00000000000
    0000000000000
   000000000000000
  00000000000000000
Source Link
lll
  • 261
  • 1
  • 8

PHP - 78

<?=($p='          ').'*
';for($s=' 0';$p=substr($p,1);){echo"$p$s
";$s.='00';}

For variable heights of 12 or below, modify the hard-coded padding in the above. (Code gets smaller the lower the height)

For variable heights of 13 or more use the following, height param is the second argument to str_pad. (Code starts at 80 bytes and doesn't grow as fast as the version with static padding)

<?=($p=str_pad('',13)).'*
';for($s=' 0';$p=substr($p,1);){echo"$p$s
";$s.='00';}

Output of php -d short_open_tag=1 tree.php

          *
          0
         000
        00000
       0000000
      000000000
     00000000000
    0000000000000
   000000000000000
  00000000000000000