I want to have a function written in PHP which can create anonymous functions which ~5 parameters and return them so I can store them in a key/value array and call them later without any knowledge about the parameters given and more than once.
E.g.
$fun();
How do I achieve the returning and the reusable calling afterwards?
Thanks in advance.
You mean something like this?
And the output:
array(3) { [0]=> string(4) "test" [1]=> string(8) "password" [2]=> string(9) "localhost" }Not sure of your use case, but for my example the output of the function could be a formatted DNS as well as the simple arrays.
As mentioned elsewhere, func_get_args would make this work with any number of arguments.