Hi,
> 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
Probably a more accurate solution would be :-
function x()
{
static $count = 0;
$count++;
switch ($count % 3)
{
case 0:
case 2: return 'shy';
case 1: return 'bitten';
}
} // x
And it's commented :-P
TTFN
D
php/general-2007-06-27.tx php-general
+----------------------------------------------------------------------------+
| Dave Restall, Computer Nerd, Cyclist, Radio Amateur G4FCU, Bodger |
| Mob +44 (0) 7973 831245 Skype: dave.restall Radio: G4FCU |
| email : [EMAIL PROTECTED] Web : Not Ready Yet :-( |
+----------------------------------------------------------------------------+
| Sooner or later you must pay for your sins. (Those who have already |
| paid may disregard this cookie). |
+----------------------------------------------------------------------------+
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php