Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have a response coming back that is JSON encoded, but when I decode it I lose the
true
/
false
attributes after using
$var = json_decode($response);
.
Here’s an example:
"domain": "my.domain.com",
"created_at": "2014-11-15 00:26:53.74059",
"valid_mx": true
I’ve even tried:
$var = json_decode($response, true);
But it still seems to drop the true/false. How can I properly pull the true/false from the response? What am I missing?
–
Your problem is with print_r, not json_decode.
print_r does not show true / false for true / false. Instead, it shows 1 / (blank).
You can use var_dump($var); or var_export($var); instead which will show you the correct values.
–
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.