NeoMarine Posted November 21, 2008 Share Posted November 21, 2008 I'm trying to loop through all the arguments passed into the function: foreach (get_func_arg() as $variableName => $variableValue){ $argumentsPassed .= $variableName."=".$variableValue.", "; } return $argumentsPassed; So, if I entered something like: $variable1="Cool"; $coolStuff="1234"; echo myFunction($variable1, $coolStuff); The output will be: $variable1=Cool, $coolStuff="1234" (or without the $'s) ANY IDEAS?? Is it even possible?? I need this because my variable names are required, and their could be any number of function arguments(variables) passed Quote Link to comment Share on other sites More sharing options...
flyhoney Posted November 21, 2008 Share Posted November 21, 2008 You could use func_get_args() in conjunction with the function this guy wrote: http://us.php.net/manual/en/language.variables.php#49997 Quote Link to comment Share on other sites More sharing options...
NeoMarine Posted November 22, 2008 Author Share Posted November 22, 2008 I tried, it doesn't work. The variable names are returned as index-numbers, eg: 0=Cool, 1=1234 I think that functions don't obtain the variable "name"... surely there is some work around though hmm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.