Posted by Michael Fesser on 06/25/07 00:30
..oO(Geoff Berrow)
>Message-ID: <467ecee0$0$10863$426a74cc@news.free.fr> from Séverin
>Richard contained the following:
>
>>Thank you for your answer
>>
>>I have many different extention to deal with and i will use switch
>>rather than ternary operator.
>
>I still find little use for switch and prefer to use an array instead.
In a situation like this a switch is the perfect solution:
switch ($foo) {
case 1: doThis(); break;
case 2: doThat(); break;
case 3: doSomething(); break;
case 4: doSomethingElse(); break;
default: doWhatever();
}
The alternative would be a cascade of 4 if-else statements ... Ugly.
Micha
[Back to original message]
|