0

I have array in my MongoDB document. When im'm printing it in PHP (print_r($user->__next_action);) i got

MongoDB\Model\BSONDocument Object
(
[storage:ArrayObject:private] => Array
    (
        [text] => Sometext
    )

)

How do I get standard PHP array from this? I need

Array
(
    [text] => Sometext
)

2 Answers 2

3

Try this

return json_decode(json_encode(iterator_to_array($user->__next_action)), TRUE);

Quick workaround to get this working.

Sign up to request clarification or add additional context in comments.

Comments

0

Well it’s an ArrayObject class so getArrayCopy should work.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.