假设我有这个数组,我如何将变量分配给A,B,C,D和E后面的值? 这是我的代码:
<?php
$request = "https://www.kimonolabs.com/api/6xlbn85i?apikey=daicEIFxONdoVm18BArKo8UekZJE1P6c&bondsnummer=21169152";
$response = file_get_contents($request);
$results = json_decode($response, TRUE);
print_r($results);
echo '<pre>'; print_r($results); echo '</pre>';
?>
这是我的输出:
Array
(
[name] => Tennismix2
[count] => 1
[frequency] => On demand
[version] => 11
[newdata] =>
[lastrunstatus] => success
[lastsuccess] => Wed Nov 19 2014 08:34:23 GMT+0000 (UTC)
[thisversionrun] => Wed Nov 19 2014 08:34:21 GMT+0000 (UTC)
[thisversionstatus] => success
[url] => http://status.mandrillapp.com/
[results] => Array
(
[collection1] => Array
(
[0] => Array
(
[A] => 21169152
[B] => Baal, A.J.W. van
[C] => M
[D] => 3
[E] => 3
)
)
)
)
我们使用API(kimonolabs)从网站上抓取数据,但这是我们能得到的最远的。 所有帮助表示赞赏。
答案 0 :(得分:1)
$var1 = $results['results']['collection1']['0']['A'];
$var2 = $results['results']['collection1']['0']['B'];
$var3 = $results['results']['collection1']['0']['C'];
$var4 = $results['results']['collection1']['0']['D'];
$var5 = $results['results']['collection1']['0']['E'];