Re: PHP 6.0 Wishlist

From: Date: Thu, 15 Sep 2005 20:57:56 +0000
Subject: Re: PHP 6.0 Wishlist
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-19007@lists.php.net to get a copy of this message
Can be done already ... sorta. switch (true) {
        case ($str == 'abc'):
                echo "it was ABC!\n";
                break;
        case (preg_match('/^[0-9]+$/i', $str)):
                echo "it was a number!\n";
                break;
        default:
                echo "it was no number :-(\n";
                break;
} *shrug* -james Ron Korving wrote:
I have another idea I came up with today: regular expression switches, but it would be difficult without adding to the syntax. switch ($str) { case "abc":
    echo "it was ABC!\n";
    break;
regcase "/^[0-9]+$/i":
    echo "it was a number!\n";
    break;
default:
    echo "it was no number :-(\n";
    break;
} Just an idea ;) Ron


« previous php.internals (#19007) next »