在CodeIgniter中从post数组获取数据 [英] Getting data from post array in CodeIgniter

查看:101
本文介绍了在CodeIgniter中从post数组获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我有一个表单发送数组在POST数组。我想读这样:

Ok, so I have a form that is sending me arrays in the POST array. I am trying to read it like so:

$day = $this->input->post("days")[0];

这不起作用。 PHP说意外[。为什么这不起作用?

This does not work. PHP says "unexpected '['". Why does this not work?

我这样做是固定的:

$days = $this->input->post("days");
$day = $days[0];

我修复了我的问题,我只是想知道为什么第一种方式不工作。

I fixed my problem, I'm just curious as to why the 1st way didn't work.

推荐答案

PHP不支持函数调用的数组陈述。它在SVN中继版本的PHP中实现,因此它可能会使其成为未来版本的PHP。现在你必须诉诸于你现在正在做的事情。对于枚举数组,还可以使用 list

Array derefencing from function calls isn't supported by PHP. It's implemented in the SVN trunk version of PHP, so it will likely make it into future versions of PHP. For now you'll have to resort to what you're doing now. For enumerated arrays you can also use list:

list($day) = $this->input->post("days");

请参阅: http://php.net/list

这篇关于在CodeIgniter中从post数组获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆