In PHP there are functions like unset() that support any number of parameter we throw at them.
I want to create a similar function that is capable of accepting any number of parameters and process them all.
Any idea, how to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In PHP, use the function
func_get_argsto get all passed arguments.An alternative is to pass an array of variables to your function, so you don’t have to work with things like
$arg[2];and instead can use$args['myvar'];or rewmember what order things are passed in. It is also infinitely expandable which means you can add new variables later without having to change what you’ve already coded.