-1
我有一個url返回一組數據作爲jSON對象,我想解碼返回的數據並將其放入PHP中的變量。我不知道該怎麼做..如何獲取jSON API數據並將其作爲變量存儲在PHP中
這是該URL的回報作爲結果
{
"result" : "ok",
"tuc" : [ {
"meanings" : [ {
"language" : "en",
"text" : "unwilling to work"
}, {
"language" : "en",
"text" : "relaxed or leisurely"
}, {
"language" : "en",
"text" : "eye: squinting because of weak muscles"
}, {
"language" : "en",
"text" : "Unwilling to do work or make an effort."
}, {
"language" : "en",
"text" : "Unwilling to do work or make an effort."
}, {
"language" : "en",
"text" : "Requiring little or no effort."
}, {
"language" : "en",
"text" : "Relaxed or leisurely."
}, {
"language" : "en",
"text" : "(optometry) Of an eye, squinting because of a weakness of the eye muscles."
}, {
"language" : "en",
"text" : "(cattle brands) Turned so that the letter is horizontal instead of vertical."
} ],
"meaningId" : null,
"authors" : [ 60172 ]
} ],
"phrase" : "lazy",
"from" : "en",
"dest" : "en",
"authors" : {
"60172" : {
"U" : "http://www.omegawiki.org/",
"id" : 60172,
"N" : "omegawiki",
"url" : "https://glosbe.com/source/60172"
}
}
}
我預計前5 DATAS作爲我的結果對象,
$text1 = "unwilling to work";
$text2 = "relaxed or leisurely";
$text3 = "eye: squinting because of weak muscles"
$text4 = "Unwilling to do work or make an effort."
$text5 = "Unwilling to do work or make an effort."
數據重複不是問題。
那麼你有什麼嘗試?看起來好像你認爲你可以在這裏發佈問題並期望人們爲你做這項工作? – Blizz
@ Blizz:首先將api數據存儲爲變量,並將其用於在我的頁面中顯示它。示例<? php echo $ text1; ?>,<? php echo $ text2; ?>,<? php echo $ text3; ?> ... –
所以基本上是的:你期待人們爲你做你的工作。 – Blizz