dst3605528 2016-03-14 14:32 采纳率: 0%
浏览 47

在codeigniter表单验证中从数组中提取值

I have a form like this :

<input type='text' name='category[]' value='firstcategory'>
<input type='text' name='category[]' value='secondcategory'>

and a validation rule like this

$this->form_validation->set_rules('category[]', 'Category Name', 'checkcategory');

how can I get the values firstcategory and secondcategory in my checkcategory callback?

After I try print_r($_POST) it showed me something like :

Array ( [category] => Array ( [0] => 'firstcategory' [1] => 'secondcategory' ) )

So in order to achieve what I want, I've tried something like this on my checkcategory callback :

$neddle = array('firstcategory' => $str['category'][0], 'secondcategory' => $str['category'][1]);

But it didn't work.

  • 写回答

1条回答 默认 最新

  • douqiandai4327 2016-03-14 14:42
    关注

    You can't, yet.

    There's a feature request for this that will be fulfilled for CodeIgniter 3.1.0: https://github.com/bcit-ci/CodeIgniter/issues/193

    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序