I have developed a new technique for my future programs to decide which function is to be fired without if/else statements. It is to create an associative array of functions and call them by a function according to argument given. I think actual representation will be better.
$_functions = array(
"names" => function() {
....
},
"orders" => function() {
....
}
);
function doLoad($toLoad) {
global $_functions;
$_functions[$toLoad]();
}
Now, a user has to write only:
doLoad("names");
wherever they want to print out names.
Question:
I will be creating a script and it will be distributed among other fellas to use it their way.
Is it better to do it like this way for my script? Is there any drawbacks of this technique?