Possible Duplicate:
PHP function with unlimited number of parameters
How to pass array as multiple parameters to function?
I want to create a function with a variable number of parameters in PHP, kinda like a souped up version of sprintf. E.g. Where sprintf might look like this:
$res = sprintf("The number is %d and the string is %s", $num, $str);
with an arbitrary number of arguments, I want to do something like this:
function my_special_printf($special, $format, ....lots of args...)
{
// do something with $special here
return sprintf($format, .. lots of args...);
}
Is this possible?
Use func_get_args();
http://php.net/manual/en/function.func-get-args.php
This function returns all the parameters in array.
or: