我使用以下输入标记从html表单发布数组:
<input type="text" name="new_service[1]['category']">
我得到这个数组:
Array
(
[1] => Array
(
['category'] => 1
['description'] => asdasd
['price'] => asdasd
['time'] => 1
)
)
当我尝试使用
获取类别值时echo $_POST['new_service'][1]['category'];
我收到此错误消息:
Notice: Undefined index: category
我做错了什么?
答案 0 :(得分:3)
您以这种方式创建的索引不是类别,而是&#39;类别&#39;即你创建一个也有单引号的索引。
所以要回应你想要的东西你应该使用:
echo $ _POST [&#39; new_service&#39;] [1] [&#34;&#39; category&#39;&#34;];
答案 1 :(得分:0)
只需使用$ _POST [&#39; new_service&#39;];然后循环