假设验证第一个数组是正常的,要么返回表单,要么像我们想要的那样继续。我们希望验证第二个数组,以便为用户提供一个验证消息,表明输入不是第一个,而是第二个数组。我们如何归还?
$var1s = array()
$var2s = array()
$form = $validation_result["form"];
$checkforthis = post('input_1')
//if the following is valid, return $validation_result and forget the rest
if($checkforthis && in_array($var1, $var1s))
return $validation_result;
//otherwise...
//how does one return the following and distinguish it from the above validation?
if($checkforthis && in_array($var2, $var2s))
return **whatgoeshere?**
//otherwise when NOT in either array
$field['failed_validation'] = true;
$field['validation_message'] = 'Please check and try again.';
答案 0 :(得分:1)
也许返回一个数组
从in_array
或use和int标识符返回针。
id:
的示例// code ...
return array(1, $validation_result);
// code ...
return array(2, $validation_result);
结果:
list($id, $result) = function();
switch ($id) {
case 1:
// Actions here with $result
break;
case 2:
// Others actions here with $result
break;
}