2011-01-26 3 views
1

最初の配列の妥当性を検証し、フォームを返すか、必要なように続けます。 2番目の配列に対して検証を行い、入力が最初の配列ではなく2番目の配列ではないという検証メッセージをユーザーに与える必要があります。これをどうやって返すのですか?1つの配列に対して入力を検証する方法、次に必要に応じて別の配列に対して入力を検証する方法は?

$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

は正直に...私はあなたの質問を理解していません。 – webbi

答えて

1

おそらく配列を返します。
in_arrayからニードルを戻すか、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; 
} 
関連する問題