PHP Function with Optional Parameters
original source : http://stackoverflow.com/questions/3978929/php-function-with-optional-parameters
To accomplish what you want, use an array Like Rabbot said (though this can become a pain to document/maintain if used excessively). Or just use the traditional optional args.
//My function with tons of optional params
function my_func($req_a, $req_b, $opt_a = NULL, $opt_b = NULL, $opt_c = NULL)
my_func('Hi', 'World', null, null, 'Red');
However, I usually find that when I start writing a function/method
with that many arguments – more often than not it is a code smell, and
can be re-factored/abstracted into something much cleaner.
//Specialization of my_func - assuming my_func itself cannot be refactored
function my_color_func($reg_a, $reg_b, $opt = 'Red')
return my_func($reg_a, $reg_b, null, null, $opt);
my_color_func('Hello', 'Universe', 'Green');