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 Link to comment https://forums.phpfreaks.com/topic/133721-php-function-argument-variable-name/ 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 Link to comment https://forums.phpfreaks.com/topic/133721-php-function-argument-variable-name/#findComment-695890 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 Link to comment https://forums.phpfreaks.com/topic/133721-php-function-argument-variable-name/#findComment-695922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.