Good afternoon
I have an avaliution tomorrow and have to do a Christmas tree using PHP with this symbol -----> *
Can anybody help me?Please
i'm running out of time
Christmas tree
Moderator: General Moderators
Re: Christmas tree
What have you done so far? What problems are you encountering?
Re: Christmas tree
Everything i just can't do it
Re: Christmas tree
So you've tried nothing and you want us to do your homework for you? Sorry, no.
Re: Christmas tree
Code: Select all
echo " *** * * **** ***** *** ***** * * * *** ***** **** ***** *****\n";
echo "* * * * * * * * * * ** ** * * * * * * * * * \n";
echo "* * * * * * * * * * * * * * * * * * * \n";
echo "* ***** **** * *** * * * ***** *** * **** **** **** \n";
echo "* * * * * * * * * * * * * * * * * * \n";
echo "* * * * * * * * * * * * * * * * * * * * * \n";
echo " *** * * * * ***** *** * * * * * *** * * * ***** *****\n"; Re: Christmas tree
Code: Select all
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*********************
***********************
*************************
***************************
Code: Select all
<?php
$levels = 15;
for($i=0;$i<$levels;$i++){
for($j=0;$j<floor(($levels-$i));$j++)
echo " ";
for($j=0;$j<(2*$i)-1;$j++)
echo "*";
echo "<br />";
}
?>Re: Christmas tree
no need for the two inner loops, just use str_repeat()
Re: Christmas tree
Nah
its no fun and christmas is all about fun! 