“数组到字符串转换”构造多维数组时出错 [英] "Array to String Conversion" error when constructing a multi-dimensional array

查看:50
本文介绍了“数组到字符串转换”构造多维数组时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有点难过,因为我收到了通知:数组到字符串

转换"尝试做表面上的事情时出错

应该是一个非常简单的任务 - 创建一个数组,并根据提交的数据为它们写一组

值POST字段。


以下代码:


$ _SESSION [" increment"] = array();

$ x = 0 //计数器 - 这将是

递增


$ _SESSION [" increment"] [$ x] = array(" increment_bond" =>

$ _POST [" increment_bond"],

" increment_amount" = $ _POST [" increment_amount"],

" increment_comm_date1" = $ _POST [" increment_comm_date1"],

" increment_comm_date2" = $ _ POST [" increment_comm_date2"],

" increment_comm_date3" = $ _POST [" increment_comm_date3"]);

它不断抛出该错误,并且不会将任何POST

值写入数组(POST值绝对是仙女t,所以

这不是问题)。


如果我转出$ _SESSION [" increment"]的值,我会得到图1A" ?!?


我肯定在某个地方潜伏着一个非常简单的错误 - 我好像b $ b似乎无法弄明白。


有什么建议或提示吗?


谢谢

Neil。

Hi,

I''m a bit stumped as I am getting a "Notice: Array to String
Conversion" error when trying to do something that on the surface
should be a very simple task - create an array, and write a set of
values to them based on data submitted from POST Fields.

Code below:

$_SESSION["increment"] = array();
$x = 0 // Counter - This will be
incremented

$_SESSION["increment"][$x] = array("increment_bond" =>
$_POST["increment_bond"],
"increment_amount" = $_POST["increment_amount"],
"increment_comm_date1" = $_POST["increment_comm_date1"],
"increment_comm_date2" =$_POST["increment_comm_date2"],
"increment_comm_date3" = $_POST["increment_comm_date3"]);
It keeps throwing out that error, and does not write any of the POST
Values to the array (the POST values are definitely getting sent, so
that is not the problem).

If I dump out the value of $_SESSION["increment"], I get "1A" ?!?

I''m sure that there is a pretty simple mistake lurking somewhere - I
just can''t seem to figure it out.

Any suggestions or hints ?

Thanks
Neil.

推荐答案

_SESSION [" increment"] = array();
_SESSION["increment"] = array();


x = 0 // Counter - This将增加



x = 0 // Counter - This will be
incremented


_SESSION [" increment"]
_SESSION["increment"]


这篇关于“数组到字符串转换”构造多维数组时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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