Home  >  Article  >  Backend Development  >  thinkphp里 表单提交数组的问题

thinkphp里 表单提交数组的问题

WBOY
WBOYOriginal
2016-06-23 14:01:031770browse

表单

<td class="norightborder">		<tbody>			<tr >				<td width="350" style="width:350px;"><input type="text" name="option[]" value="" class="px" style="width:350px;"></td>				<td><input type="text" name="listorder[]" value="1" style="width:35px;" class="px"></td>							</tr>			<tr >				<td width="350" style="width:350px;"><input type="text" name="option[]" value="" class="px" style="width:350px;"></td>				<td><input type="text" name="listorder[]" value="2" style="width:35px;" class="px"></td>							</tr>			<tr >				<td width="350" style="width:350px;"><input type="text" name="option[]" value="" class="px" style="width:350px;"></td>				<td><input type="text" name="listorder[]" value="3" style="width:35px;" class="px"></td>							</tr>			


提交到后台打印出的数组是这样的
string(5) "Array"    怎么才能显示出值


回复讨论(解决方案)

你是如何打印的?

print_r($_POST['listorder']);

你这是echo出来的吧

  你在接收页面 直接print_r($_POST);
  看看什么效果, 你这应该是用var_dump()输出的吧?

表单没有问题
print_r($_GET['listorder'])就可以了

你是如何打印的?   我是这么打印的   print_r($_POST)  

  你在接收页面 直接print_r($_POST);
  看看什么效果, 你这应该是用var_dump()输出的吧?   我刚开始是 print_r($_POST) 打印的  打印出来是   ['listorder']=array   后来  我想查看一下数据类型才用 var_dump    发现是  string

你没有用 thinkphp 提供的传入数据处理机制吗?
你自己做了处理?
贴出相关代码

你没有用 thinkphp 提供的传入数据处理机制吗?
你自己做了处理?
贴出相关代码
谢谢斑竹的热心回答   找了半天是这边给过滤了   但是为什么trim过滤就不能提交数组了

        // 系统变量安全过滤        if(C('VAR_FILTERS')) {            $filters    =   explode(',',C('VAR_FILTERS'));            foreach($filters as $filter){                // 全局参数过滤                $_POST  =   array_map($filter,$_POST);                $_GET   =   array_map($filter,$_GET);            }        }$filters 是 Array(    [0] => trim)
       

如果  $_POST 是多维数组,则除一维都会出问题

这样写比较好
array_walk_recursive($_POST, 'trim');
array_walk_recursive($_GET, 'trim');

谢谢大家的热心帮忙

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn