【发布时间】:2017-11-15 23:48:26
【问题描述】:
我有一个包含以下值的数组,
Array(
[new_count] => 1
[updated_count] => 0
[error_count] => 0
[error_indices] => Array
(
)
[unmodified_indices] => Array
(
)
[persisted_recipients] => Array
(
[0] => ZEBhcy5jb20=
)
[errors] => Array
(
)
)
我试图只将这个值传递给一个变量,
[persisted_recipients] => Array
(
[0] => ZEBhcy5jb20=
)
$recipient_id = $array_retorno['persisted_recipients'][0];
但我收到以下错误
未定义的偏移量:0 [APP\Controller\PostsController.php,第 129 行]
怎么了?
【问题讨论】:
-
那么
$array_retorno是一个包含多个数组的数组?听起来你需要$array_retorno[5][0]。 -
您能
var_dump($array_retorno)并在问题中发布结果吗?我不确定数组中的实际内容。 -
从 var_dump 数组返回 (7) { ["new_count"]=> int(1) ["updated_count"]=> int(0) ["error_count"]=> int(0) [ "error_indices"]=> 数组(0) { } ["unmodified_indices"]=> 数组(0) { } ["persisted_recipients"]=> 数组(1) { [0]=> 字符串(20) "ZHNkc0Bkc2RzZC5jb20=" } [“错误”]=> 数组(0){ } }
-
您在此处显示的数据和代码不会导致该错误。请使用可重现您的问题的工作代码 sn-p 更新您的帖子!
标签: php cakephp cakephp-2.0