请在迭代该数组时需要帮助。由于某些原因,我无法使其正常工作。我想回显 name 属性。
C:\wamp\www\yousave\routes\web.php:18:
object(stdClass)[252]
public 'status' => boolean true
public 'msg' => string 'successfully' (length=12)
public 'response' =>
array (size=7394)
0 =>
object(stdClass)[280]
public 'id' => string '1' (length=1)
public 'name' => string 'Euro US Dollar' (length=14)
public 'decimal' => string '4' (length=1)
public 'symbol' => string 'EUR/USD' (length=7)
1 =>
object(stdClass)[281]
public 'id' => string '2' (length=1)
public 'name' => string 'Euro Swiss Franc' (length=16)
public 'decimal' => string '4' (length=1)
public 'symbol' => string 'EUR/CHF' (length=7)
2 =>
object(stdClass)[283]
public 'id' => string '3' (length=1)
public 'name' => string 'Euro Japanese Yen' (length=17)
public 'decimal' => string '2' (length=1)
public 'symbol' => string 'EUR/JPY' (length=7)
到目前为止,我的代码是
$url = 'https://fcsapi.com/api/forex/list?access_key=';
$json = file_get_contents($url);
$json = json_decode($json, true);
for($i=0; $i <= count($json['response'][''][$i]); $i++){
echo $json['response'][$i]['name'];
}
预先感谢