PHP Loop?

Discussion in 'PHP' started by Turtle85, Oct 25, 2010.

  1. #1
    Is there a function of some sort in PHP where I have the script and can make it loop X amount of times? Please help
     
    Turtle85, Oct 25, 2010 IP
  2. wing

    wing Active Member

    Messages:
    210
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #2
    for loop, 10 times
    for ($i=0; $i < 10; $i++) {
    echo $i; // prints 0123456789
    }
    PHP:
    while loop 10 times
    $i=0;
    while ($i < 10) {
    echo $i; // prints 0123456789
    $i++;
    }
    PHP:
     
    wing, Oct 25, 2010 IP
  3. Amator

    Amator Well-Known Member

    Messages:
    1,424
    Likes Received:
    55
    Best Answers:
    0
    Trophy Points:
    165
    #3
    I think you better start with reading some PHP tutorials. This is really a basic PHP statement that you need to understand before programming more advanced codes.
     
    Amator, Oct 25, 2010 IP
  4. hakikat.choudhary

    hakikat.choudhary Peon

    Messages:
    121
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Habitually while you engrave code, you desire the same wedge of system to run over and over another time in a chain. in its place of totaling numerous roughly equal lines in a characters we can use loops to execute a mission like this.
     
    hakikat.choudhary, Oct 25, 2010 IP
  5. anh2.info

    anh2.info Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    try to read basis PHP if you want to know and understand it.May be you make better then you want
     
    anh2.info, Oct 25, 2010 IP
  6. w47w47

    w47w47 Peon

    Messages:
    255
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    wing answered your question already i think. ;)

    + you can use foreach(){}

    read on php.net on how to use it.
     
    w47w47, Oct 26, 2010 IP