Nice to hear you've got it working. At a very brief glance I can just see two things that could be improved upon:
if(!is_array($arg_list[$i])) {
$parameter[] = "$arg_list[$i]";
} else {
$parameter[] = $arg_list[$i];
}
Unless you really do want to cast non-array arguments to strings (and what about objects or resources?), this test is unneeded, and could be replaced by
$parameter[] = $arg_list[$i];
The other thing is that you can save yourself a bit of effort (including the loop alluded to above) by preprocessing your arguments list:
$arg_list = func_get_args();
$function_name = array_shift($arg_list);
Now you can replace $arg_list[0] with $function_name, and $arg_list contains only the arguments to that function.
Actually, you don't even need $function_name at all: when you declared func() it was with two parameters, so $numargs will always be at least two, with $func containing the name of the function; therefore
array_shift($arg_list);
alone will tidy up that array (which, as it happens, will be guaranteed to have at least one element) and $func will then replace $arg_list[0].
So, with that in mind:
function func($func,$args) {
// get an array of the arguments (like explode sort of)
$arg_list = func_get_args();
array_shift($arg_list);
// check to see if your function exists
// the first arg will always be the name of the function
if (function_exists($func)) {
return call_user_func_array($func,$arg_list);
} else {
// if the function doesn't exist check to see if it's out there
if (file_exists($_SERVER['DOCUMENT_ROOT']."/functions/$func.function.php")) {
// go get it if the file does exist
@include_once $_SERVER['DOCUMENT_ROOT']."/functions/$func.function.php";
return call_user_func_array($func,$arg_list);
} else {
// woops, can't find anything...
echo "Could not load $func.function.php.";
}
}
}