How to echo JSON in PHP [closed] How to echo JSON in PHP [closed] json json

How to echo JSON in PHP [closed]


if you want to encode or decode an array from or to JSON you can use these functions

$myJSONString = json_encode($myArray);$myArray = json_decode($myString);

json_encode will result in a JSON string, built from an (multi-dimensional) array.json_decode will result in an Array, built from a well formed JSON string

with json_decode you can take the results from the API and only output what you want, for example:

echo $myArray['payload']['ign'];


Native JSON support has been included in PHP since 5.2 in the form of methods json_encode() and json_decode(). You would use the first to output a PHP variable in JSON.