Posted by Janwillem Borleffs on 06/25/07 11:36
Michael Fesser schreef:
> 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.
>
Like Geoff, I also favor the use of arrays. I wrote the following
document some time ago on the subject:
http://docs.jwscripts.com/PHP%20spaghetti.doc
JW
[Back to original message]
|