checking a variable against multiple values

    Date: 03/09/06 (PHP Community)    Keywords: no keywords

    aside from dumping the values into an array and then using in_array(), is it possible to write a comparison statement that checks against multiple values? i often find myself doing something like


    if ($x == 1 || $x == 2 || $x == 3) {
    do_some_junk();
    }


    which seems kind of messy. it'd be nice if there was something like


    if ($x in(1,2,3)) {
    do_some_junk();
    }


    i've tried experimenting but haven't come up with anything.

    Source: http://community.livejournal.com/php/423794.html

« Output Validation? || .htaccess help »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home