1

I get the following output from an API call:

$json = file_get_contents($service_url);

the var_dump of $json gives me:

string(308) " [{"Transaction_ID":2805579},{"Transaction_ID":2777876},{"Transaction_ID":2808406}]"

However, var_dump(json_decode($json)) returns a null.

What am I doing wrong?

3
  • 1
    Should't you use json_decode instead of decode_json? Commented Aug 23, 2015 at 21:18
  • sorry that was a typo. I am using json_decode Commented Aug 23, 2015 at 21:43
  • 2
    "NULL is returned if the json cannot be decoded or if the encoded data is deeper than the recursion limit. " php.net/manual/en/function.json-decode.php Commented Aug 23, 2015 at 21:56

1 Answer 1

1

See: http://php.net/manual/en/function.json-decode.php

decode_json isn't a function, you should use json_decode

var_dump(json_decode($json))
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.