How can I convert a PHP function's parameter list to an associative array?
I want to convert the arguments to a function into an associative array with keys equal to the parameter variable names, and values equal to the parameter values. PHP: function my_function($a, $b, $c) { // <--- magic goes here to create the $params array var_dump($params['a'] === $a); // Should result in bool(true) var_dump($params['b'] === $b); // Should result in bool(true) var_dump($params['c'] === $c); // Should result in bool(true) } How can I do this? The you can do this using compact : function myFunc($a, $b, $c) { $params = compact('a', 'b', 'c'); // ... } Or, get_defined_vars() will