mrkeck Sharing the Love

13Jan/150

json_decode not working from database query

Short answer:

json_decode(html_entity_decode($json));

Had some JSON in a database that I wanted to use in my PHP code, but it keep coming up NULL.
Did a var_dump and the number of characters didn't match. Tried all sorts of trims and tried converting to utf8.
Ended up calling html_entity_decode() on the JSON string, then json_decode worked perfectly!

Filed under: PHP Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.