如何在 PHP 中回显 JSON [英] How to echo JSON in PHP

查看:34
本文介绍了如何在 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'];

这篇关于如何在 PHP 中回显 JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆