0

I have an array with the following values,

Array(
[new_count] => 1
[updated_count] => 0
[error_count] => 0
[error_indices] => Array
    (
    )

[unmodified_indices] => Array
    (
    )

[persisted_recipients] => Array
    (
        [0] => ZEBhcy5jb20=
    )

[errors] => Array
    (
    )

)

and I'm trying to pass to a variable only this value,

[persisted_recipients] => Array
    (
        [0] => ZEBhcy5jb20=
    )

$recipient_id = $array_retorno['persisted_recipients'][0];

but I'm getting the following error

Undefined offset: 0 [APP\Controller\PostsController.php, line 129]

what is wrong?

4
  • So $array_retorno is an array that contains multiple arrays? Sounds like you need $array_retorno[5][0]. Nov 15, 2017 at 23:52
  • Can you var_dump($array_retorno) and post results in the question? I am not sure what is actually in the array.
    – paulz
    Nov 15, 2017 at 23:58
  • return from var_dump array(7) { ["new_count"]=> int(1) ["updated_count"]=> int(0) ["error_count"]=> int(0) ["error_indices"]=> array(0) { } ["unmodified_indices"]=> array(0) { } ["persisted_recipients"]=> array(1) { [0]=> string(20) "ZHNkc0Bkc2RzZC5jb20=" } ["errors"]=> array(0) { } }
    – Henrique
    Nov 16, 2017 at 0:17
  • 1
    The data and the code that you are showing here will not cause that error. Please update your post with a working code snippet that reproduces your problem!
    – ndm
    Nov 16, 2017 at 11:11

1 Answer 1

-1

try to get_file_contents() function to fetch output data. or try
json_decode(json_encode($array), true).

1
  • Dude, the array he shows us, just output from the php code, Nov 16, 2017 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.