0

I am having a json object $result

I do this:

$json = json_decode($result, true);

Here is the output if I use this:

var_dump($json)

is this:

array(15) { ["id"]=> int(1)  ["name"]=> array(16) { ... } }

If I do this:

echo $json['id'];
echo $json['name'];

The id is printed correctly : 1 But in the name this is printed: Array

How can I get that array and print it?

1
  • You haven't shown enough of the object. What do you get if you do this? var_dump($json['name']) Commented Dec 20, 2013 at 23:24

1 Answer 1

1

Several ways:

print_r($json['name']);
var_dump($json['name']);

Or manual with preferred delimiter:

echo implode(", ", $json['name']);

However you should check the function responsible for making that JSON string, because you expect a string instead of array.

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

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.