Sending multiple arguments to a function can be done using a parameter string. This is just like a URL that has data encoded into it. For example, if you wanted to send two parameters (called parameter1 and parameter2) to a function then you would use the following string.
To use this in the function you create the function as normal with a single parameter. This single parameter is the string that will contain all of your arguments.
- function test($arguments)
You must run the parse_str() function on the arguments parameter to extract the data you need. You can then call the parameters by their names as variables.
Note that it is still prudent to check to see that the variable has been created before trying to use it. Otherwise the following error will be produced (if you have error reporting turned on to a high level).
Notice: Undefined variable: parameter2 in test.php on line 5
If you want to send an array of information to the function then just include square brackets. The following function will create an array of two items, as well as our two parameters.