Re: Re: PHP Brain Teasers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux