SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    creating a simpler if statement

    Hi all,

    Im trying to create an if statement that would be able to do the following:

    Code:
    	if (($x == 1) or ($x == 6) or ($x == 11) or ($x == 16) or ($x == 21)){
    and
    Code:
    	if (($x == 5) or ($x == 10) or ($x == 15) or ($x == 20) or ($x == 25)){
    However, is there any way of creating an easier if statement as I wish the value f $x to eventually reach much higher numbers (say 1,000) and I do not want to have to keep adding to each of these if statements.

    Any ideas?

  2. #2
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    First one:
    PHP Code:
    if($x == 1){

    Second one:
    PHP Code:
    if($x == 0){

    -- Jelena --

  3. #3
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Those are modulo operator btw. It returns the remainder of dividing $x by 5.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •