我有一個這樣的形式:提取值
<input type='text' name='category[]' value='firstcategory'>
<input type='text' name='category[]' value='secondcategory'>
像這樣
$this->form_validation->set_rules('category[]', 'Category Name', 'checkcategory');
我怎麼能得到firstcategory
和secondcategory
中值的驗證規則我checkcategory
回調?
我嘗試print_r($_POST)
後,它給我這樣的:
Array ([category] => Array ([0] => 'firstcategory' [1] => 'secondcategory'))
因此,爲了達到我想要的,我已經試過這樣的事情在我checkcategory
回調:
$neddle = array('firstcategory' => $str['category'][0], 'secondcategory' => $str['category'][1]);
但它沒有工作。
你可以給他們不同形式的名字 - 做驗證 - ,然後根據需要將它們結合起來?它似乎也將有所幫助,如果有驗證錯誤回聲出來...... – cartalot