A lot to take in with that title I know, what I'm trying to do I don't believe to be too complicated but I'm having a hard time understanding something. Is what I'm trying to do is create a multidimensional array of data that I will use to dynamically call a function using:
call_user_func_array($function, $variables)
Now here's how I have my array setup.
I have 3 main named keys (representing the name of the functions):
string, numeric, username.
In these arrays I have the variables that will be passed to each one of those functions:
username which I need to take 2 additional parameters that I use another nested array to take care of.
password which I also need to take 2 additional parameters.
confirmPassword which I need 2 additional parameters for.
So I need it to look something like this when all the code is done computing:
call_user_func_array(string($username, @param1, @param2));
call_user_func_array(string($password, @param1, @param2));
call_user_func_array(string($confirmPassword, @param1, @param2));
call_user_func_array(string($firstName));
call_user_func_array(string($lastName));
call_user_func_array(numeric($memberLevel));
call_user_func_array(numeric($memberId));
call_user_func_array(username($username));
Here's the code with the data and the functions and variables:
$data = array (
'username' => 'username',
'password' => md5('pass'),
'confirmPassword' => md5('pass'),
'firstName' => 'firstname',
'lastName' => 'lastname',
'memberLevel' => '2',
'memberId' => '4',
);
$val_array = array(
'string' => array(
array('username', 3, 4),
array('password', 4, 3),
array('confirmPassword', 4, 3),
'firstName', 'lastName'),
'numeric' => array('memberLevel', 'memberId'),
'username' => array('username'),
);
$error = array();
foreach ($val_array as $var => $val_err) {
// if (is_array($val_array[$var])) {
// }
$function = $var;
foreach ($val_err as $var) {
//$error[] = $var;
echo "validate_".$function."(".$data[$var].")\n";
}
}
Am I making any sense to anybody? Thanks guys.