如何在 PHP 中回显 JSON
我只需要在 PHP 中使用 cURL 和 JSON 的一些帮助,因为我从来没有真正开始这样做.我想要完成的是把付款的标志和回应它,同时限制最新的捐赠可以先发布多少.
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.
网址:http://api.buycraft.net/query?secret=83d043249170343dd048d4da62387f6cb39ed97f&action=payments
如果你想从 JSON 编码或解码数组,你可以使用这些函数
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 将产生一个由(多维)数组构建的 JSON 字符串.json_decode 将产生一个由格式良好的 JSON 字符串构建的数组
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
使用 json_decode 您可以从 API 中获取结果并只输出您想要的内容,例如:
with json_decode you can take the results from the API and only output what you want, for example:
echo $myArray['payload']['ign'];