I'm working on a CMS, and I'm looking for a way to convert a list of function arguments, into an array. For example:
function testfunction($param1, $param2){
$string = "Param1: $param1 Param2: $param2";
return $string;
}
$funcname = 'testfunction';
$params = "'this is, parameter 1', 'this is parameter2'";
//This doesnt work, sends both parameters as the first, dont know why.
echo call_user_func($funcname, $params);
//So I want to split the parameter list:
$paramsarray = preg_split('%Complex Regex%', $params);
//And call thusly:
echo call_user_func_array($funcname, $paramsarray);
I dont know what kind of regex to use here.... I could just explode by ',' but that would explode all commas contained in strings, arrays etc... So I need a regex to do this, I'm ok with regexes, but it seems like there would be a lot of rules in this.