1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

php help

Discussion in 'PHP' started by johny321, Jul 28, 2009.

  1. #1
    I have work of showing digit after 4. suppose i have a loop of 1 to 12 . I want output just like 4,8,12
    SEMrush
     
    johny321, Jul 28, 2009 IP
    SEMrush
  2. krishmk

    krishmk Well-Known Member

    Messages:
    1,374
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    185
    #2
    You can use Modulus operator to accomplish this.

    if (($num % 4) == 0)
    {
    echo $num;
    }
     
    krishmk, Jul 28, 2009 IP
  3. vetrivel

    vetrivel Peon

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    is this help you.

    for($var=0;$var<=12;$var++){
    if($var%4==0)
    echo $var;
    }

     
    vetrivel, Jul 28, 2009 IP