Re: Re: PHP Brain Teasers

From: Date: Wed, 27 Jun 2007 08:41:51 +0000
Subject: Re: Re: PHP Brain Teasers
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-257834@lists.php.net to get a copy of this message
Colin Guthrie wrote:
Daniel Brown wrote:
What the hell? Why not start a thread that can be fun and challenging for all of us. It's something I haven't seen done
Here's another quickie: Dead simple one! <?php function x($x) { switch ($x) {
    case 1: return 'bitten';
    case 2: return 'shy';
} }
Surely this should be... function x() {
    static $count = 0;
    $count++;
    switch ($count)
    {
        case 1: return 'bitten';
        case 2: return 'shy';
    }
    return '';
} -Stut -- http://stut.net/

« previous php.general (#257834) next »