Just a thought, but instead of a switch statement, you can have a capture system available for this ...
so for a list of possible things like
item1, item2, ..., itemN
you can try something like
function item1action ( ) { } function item2action ( ) { } function itemNaction ( ) { }
and have some default method, for example
function itemDefaultAction ( ) { }
so for the previous switch statement you could do
$function = "{$item}action"; if (! function_exists($function)) { return itemDefaultAction(); } call_user_func($function); return call_user_func($function)
source share