Jump to content

Help me please


Miqayel

Recommended Posts

How to build this whit Php loops

*                           

**

***

****

*****

******

*******

********

       *

      **

     ***

    ****

   *****

  ******

 *******

********

 

 

********

*******

******

*****

****

***

**

 

*

********

 *******

  ******

   *****

    ****

     ***

      **

       *

Link to comment
Share on other sites

Here is a starting point

http://php.net/for.

 

Learn how to use a for loop and have a go at it yourself. Get stuck and we will try to help you. We WILL not provide code for you.

 

Copy and pasting code will not teach you how to program. Understanding the problem and actually writing code is what helps you to learn to program.

 

What you are attempting to do is something that anyone can achieve if you have learned the very basics of PHP. The PHP documentation is a great resource for you if you are new to the language.

Edited by Ch0cu3r
Link to comment
Share on other sites

 

i'm not waited that you will do my homework instead of me .
i done this 
$x=null;
 
for ($i=0; $i <= 8 ; $i++) { 
echo $x .'*' .'<br>' ;
$x.='*';
}
but it doesn't work with others

 

That is a good start. For the others you will need to write separate for loops for outputting the remaining patterns. Afterwards consider re-factoring your code into reusable functions

 

 

 

Can i do something like this ?

You can pad the string with whatever characters you want. You don't have to pad your lines with  . Your could instead apply  white-space: pre  CSS styling to the HTML element your patterns are contained in.

 

 

 

And one more thing: i can't use arrays.

Who mentioned arrays? I see no need for arrays in this exercise. A for loop is all that is required. You may find the following functions helpful str_repeat and str_pad as well.

Link to comment
Share on other sites

Sure sounds like you want someone to write this for you. 

 

If you are attempting to learn php or even learn how to program, you have to do the learning yourself.  There is a certain amount of intelligence that has to be used to do this kind of work, and that use begins in the beginning. 

 

Good luck.  You may get some well-meaning reader here who will jump right in and solve this problem for you, but I feel that would be a serious injustice to your learning process.

 

Besides - why are even attempting this exercise?  Did you dream this up?  If so, why did you start with such a tricky project?  Try something simpler to get comfortable with writing simple php and solving simple problems.   Or is this actually 'homework'?

Link to comment
Share on other sites

 

How can i do this ???

for ($i=1; $i < 9 ; $i++) { 
$x.='*';
so echo $x when $i = 8 afther  echo $x when $i =7 ...and so on :)
};

 

A for loop can also count backwards too. To so you'd use the opposite operators for each expression.

 

The < operator means less than. The opposite operator would be the > (greater than) operator

$i++ means increment $i by one. The opposite operator would be $i-- which means deincrement $i by one.

Link to comment
Share on other sites

Sure sounds like you want someone to write this for you. 

 

If you are attempting to learn php or even learn how to program, you have to do the learning yourself.  There is a certain amount of intelligence that has to be used to do this kind of work, and that use begins in the beginning. 

 

Good luck.  You may get some well-meaning reader here who will jump right in and solve this problem for you, but I feel that would be a serious injustice to your learning process.

 

Besides - why are even attempting this exercise?  Did you dream this up?  If so, why did you start with such a tricky project?  Try something simpler to get comfortable with writing simple php and solving simple problems.   Or is this actually 'homework'?

You honestly irritate me  :-\
How much can you talk about self-directed learning??
I just missed the lesson because I was sick!!!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.