如何在PHP中回传JSON [英] How to echo JSON in PHP
问题描述
我只需要一点帮助在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.
URL:< a href =http://api.buycraft.net/query?secret=83d043249170343dd048d4da62387f6cb39ed97f&action=payments =noreferrer> 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将产生一个Array,从一个形成良好的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
构建,你可以从API获取结果,只输出你想要的,例如:
with json_decode you can take the results from the API and only output what you want, for example:
echo $myArray['payload']['ign'];
这篇关于如何在PHP中回传JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!