SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Enthusiast poil11's Avatar
    Join Date
    Aug 2000
    Location
    it look me along time to do that...
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if (($name == "bobby") || ($name == "jerrit") || ($name == "tommy"))

    how can i, or can i combine these if equal to statements?
    I will Tell you what is wrong with your website and maybe what you can do to make it better.
    Professional Web Site Reviews ... Usability ...
    Contact Me god@stillsucks.com for more information ...
    look at my other reviews, to see what i have done.

  2. #2
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm assuming you use PHP since you used == instead of eq....

    if( ($str == 'lalal') && ($str == 'laeeee') ) { do stuff }

    && means and, || means or. If one of the &&s is false, the whole thing is false. If all of the ||s are false, then the whole thing is false.

  3. #3
    SitePoint Enthusiast poil11's Avatar
    Join Date
    Aug 2000
    Location
    it look me along time to do that...
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    my question is, instead of having all those or statements, in php (sorry) how can i combine them like ($name == "bobby" || "jerrit" || "tommy") is that how you would do it? or how do you do it.
    I will Tell you what is wrong with your website and maybe what you can do to make it better.
    Professional Web Site Reviews ... Usability ...
    Contact Me god@stillsucks.com for more information ...
    look at my other reviews, to see what i have done.

  4. #4
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm a bit rusty on the PHP language constructs (like each) but here's how you'd do it.

    $ok_vals[0] = "one of the ok values";
    $ok_vals[1] = "another one of the ok values";
    $i = 0;
    while($ok_vals[$i] == $name) {
    ++$i;
    if($i == count($ok_val))
    { Do whatever you wanted to do }
    }

  5. #5
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps a switch statement?

    switch ($name)
    {
    case "peter":
    case "someoneelse":
    case "bobby":

    echo "hello!";

    break;
    }

    probably more complicated than doing (() || ()) etc, but this might be what you're after?

  6. #6
    SitePoint Enthusiast poil11's Avatar
    Join Date
    Aug 2000
    Location
    it look me along time to do that...
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ya that will work, i don't know exaclty what i was looking for, just something that wouldn't take up so much, i have about 8 or statements. i guess i could just create another row in mysql or something. i am just wondering of all those or statements slow things down. how would you go about doing sucha thing.
    I will Tell you what is wrong with your website and maybe what you can do to make it better.
    Professional Web Site Reviews ... Usability ...
    Contact Me god@stillsucks.com for more information ...
    look at my other reviews, to see what i have done.


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
  •