parameter

PHP Logo

Using Multiple Arguments To A Function With parse_str() In PHP

12th April 2008 - 3 minutes read time

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.

parameter1=value1&parameter2=value2

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.

Read the full article