0

I can't access my json and would like to know where the error is.

$json = json_encode($data);
// string(1065) "[{"id":"test123","key":["one",...

Then I decode it to make it accessable via this command:

$json = json_decode($json, true);

// Output:
array(3) {
  [0]=>
  array(4) {
    ["id"]=>
    string(14) "test123"

When I want to echo it, it gives me:

echo $json[0];

Array to string conversion in

Masivuye Cokile
  • 4,754
  • 3
  • 19
  • 34
Magiranu
  • 299
  • 4
  • 27

1 Answers1

5

Use print_r for array, echo is used to display a string that's why it's giving error.

print_r($json);
A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103