loop like this in php

Discussion in 'PHP' started by ironmankho, Dec 14, 2012.

  1. #1
    loop like this in php

    for ($i=1; $i<=50; $i++)
    {
    echo "The number is " . $i . "<br />";
    }

    i want this type of result in php

    :eek:utput:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    [this is ad]
    21
    22
    23
    24
    25
    26
    27
    28
    29
    20
    [this is ad]
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    [this is ad]
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    [this is ad]
     
    ironmankho, Dec 14, 2012 IP
  2. ankur.mhatre

    ankur.mhatre Active Member

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #2
    Create a variable count and use it to insert ad after each 10 increments.
     
    ankur.mhatre, Dec 14, 2012 IP
  3. ironmankho

    ironmankho Active Member

    Messages:
    393
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    plz can you example?
     
    ironmankho, Dec 14, 2012 IP
  4. ironmankho

    ironmankho Active Member

    Messages:
    393
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #4
    for ($i=1; $i<=50; $i++)
    {
    echo $i . "<br />";
    if ($i % 10 == 0) {
    echo "[this is ad]<br />";
    }
    }
     
    ironmankho, Dec 14, 2012 IP