[英]Error in storing data through API
I want to call the data from API to store in my variable. 我想从API调用数据以存储在我的变量中。 My Code:
我的代码:
<?php $url = "https://api.steampowered.com/ICSGOServers_730/GetGameMapsPlaytime/v1/?format=json&key=E5F331493A95AA54FD1230551754AB19&mapgroup=operation&gamemode=casual&interval=month";
$mapinfo = json_decode(file_get_contents($url), true);
$b = $mapinfo['result'];
?>
<!DOCTYPE html>
<html>
<head>
<title>Operation Maps Stats</title>
</head>
<body>
<?php echo "$b"; ?>
</body>
</html>
Error: Notice: Array to string conversion in D:\\xampp\\htdocs\\operation\\index.php on line 14 Array 错误:注意:第14行数组D:\\ xampp \\ htdocs \\ operation \\ index.php中的数组到字符串的转换
Write print_r($b);
写
print_r($b);
instead of echo "$b"
on line 14 because result is array. 而不是在第14行显示
echo "$b"
,因为结果是数组。
Line 14: <?php echo "$b"; ?>
第14行:
<?php echo "$b"; ?>
<?php echo "$b"; ?>
You have to change to <?php echo $b; ?>
<?php echo "$b"; ?>
您必须更改为<?php echo $b; ?>
<?php echo $b; ?>
Because you are treating $b
like a string <?php echo $b; ?>
因为您将$b
当作字符串对待
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.