Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to echo JSON in PHP [closed]

Tags:

I just need a little help with using cURL and JSON in PHP since I never actually got around to doing this. What I am trying to accomplish is to take the ign of the payment and echoing it, also limiting on how much can be posted by the latest donation first.

URL: http://api.buycraft.net/query?secret=83d043249170343dd048d4da62387f6cb39ed97f&action=payments

like image 698
Itsyuka Avatar asked Mar 07 '12 08:03

Itsyuka


1 Answers

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']; 
like image 158
Bas Tuijnman Avatar answered Sep 18 '22 08:09

Bas Tuijnman