已关闭,此问题需要更focused。目前不接受答复。
**想改善这个问题吗?**更新问题,使其仅通过editing this post关注一个问题。
昨天关门了。
Improve this question
我得到了一个数组的结果:
array(3) {
["code"]=> string(1) "0"
["data"]=> array(1) {
[0]=> array(10) {
["adjEq"]=> string(0) ""
["details"]=> array(3) {
[0]=> array(25) {
["availBal"]=> string(17) "1306.166306013251"
["availEq"]=> string(17) "1306.166306013251"
["cashBal"]=> string(17) "1662.567065013253"
["ccy"]=> string(4) "USDT"
["crossLiab"]=> string(0) ""
["disEq"]=> string(18) "1502.2602611547543"
["eq"]=> string(17) "1501.869775013251"
["eqUsd"]=> string(18) "1502.2602611547543"
["fixedBal"]=> string(1) "0"
["frozenBal"]=> string(10) "195.703469"
["interest"]=> string(0) ""
["isoEq"]=> string(1) "0"
["isoLiab"]=> string(0) ""
["isoUpl"]=> string(1) "0"
["liab"]=> string(0) ""
["maxLoan"]=> string(0) ""
["mgnRatio"]=> string(16) "61.6659053967789"
["notionalLever"]=> string(17) "2.158184040937505"
["ordFrozen"]=> string(1) "0"
["spotInUseAmt"]=> string(0) ""
["stgyEq"]=> string(1) "0"
["twap"]=> string(1) "0"
["uTime"]=> string(13) "1685067331617"
["upl"]=> string(19) "-160.69729000000203"
["uplLiab"]=> string(0) ""
}
[1]=> array(25) {
["availBal"]=> string(7) "0.01998"
["availEq"]=> string(7) "0.01998"
["cashBal"]=> string(7) "0.01998"
["ccy"]=> string(3) "LTC"
["crossLiab"]=> string(0) ""
["disEq"]=> string(10) "1.64622213"
["eq"]=> string(7) "0.01998"
["eqUsd"]=> string(18) "1.7328654000000001"
["fixedBal"]=> string(1) "0"
["frozenBal"]=> string(1) "0"
["interest"]=> string(0) ""
["isoEq"]=> string(1) "0"
["isoLiab"]=> string(0) ""
["isoUpl"]=> string(1) "0"
["liab"]=> string(0) ""
["maxLoan"]=> string(0) ""
["mgnRatio"]=> string(0) ""
["notionalLever"]=> string(1) "0"
["ordFrozen"]=> string(1) "0"
["spotInUseAmt"]=> string(0) ""
["stgyEq"]=> string(1) "0"
["twap"]=> string(1) "0"
["uTime"]=> string(13) "1683772592570"
["upl"]=> string(1) "0"
["uplLiab"]=> string(0) ""
}
[2]=> array(25) {
["availBal"]=> string(12) "13.769813403"
["availEq"]=> string(12) "13.769813403"
["cashBal"]=> string(12) "13.769813403"
["ccy"]=> string(4) "DOGE"
["crossLiab"]=> string(0) ""
["disEq"]=> string(17) "0.876792868436025"
["eq"]=> string(12) "13.769813403"
["eqUsd"]=> string(18) "0.9742142982622499"
["fixedBal"]=> string(1) "0"
["frozenBal"]=> string(1) "0"
["interest"]=> string(0) ""
["isoEq"]=> string(1) "0"
["isoLiab"]=> string(0) ""
["isoUpl"]=> string(1) "0"
["liab"]=> string(0) ""
["maxLoan"]=> string(0) ""
["mgnRatio"]=> string(0) ""
["notionalLever"]=> string(1) "0"
["ordFrozen"]=> string(1) "0"
["spotInUseAmt"]=> string(0) ""
["stgyEq"]=> string(1) "0"
["twap"]=> string(1) "0"
["uTime"]=> string(13) "1683772167400"
["upl"]=> string(1) "0"
["uplLiab"]=> string(0) ""
}
}
["imr"]=> string(0) ""
["isoEq"]=> string(1) "0"
["mgnRatio"]=> string(0) ""
["mmr"]=> string(0) ""
["notionalUsd"]=> string(0) ""
["ordFroz"]=> string(0) ""
["totalEq"]=> string(18) "1504.9673408530166"
["uTime"]=> string(13) "1685072984612"
}
}
["msg"]=> string(0) ""
}
我想知道的是如何把它作为一个单独的变量取出来??
有人能帮我吗?
找了两天了,还是没有结果
1条答案
按热度按时间kr98yfug1#
我认为你首先需要使用像
curl
,file_get_contents
这样的函数向API端点发出请求,或者像Guzzle
这样的PHP包可以随意使用任何一个,正如我看到的那样,你已经得到了响应,所以然后使用json_decode
函数将其解码为JSON并访问数据。下面是一个示例代码片段,演示了如何在PHP中从OKEx API响应中提取数据:
请注意,您需要修改代码以匹配您请求的特定API端点和您想要从响应中提取的数据,但您必须查看将
foreach
放置在何处以及如何保护它,因为响应并不总是相同的。