php - 如何获得这个值
问题描述
如何获取3508
和31472
从中获取:
$info = {"ioc":true,"sid":3702088,"ci":3508,"cp":{"id":93006,"t":102,"s":true},"pr":25000,"whid":31472}
我使用json_decode
,但结果是:
“未捕获的错误:stdClass 类的对象无法转换为字符串......”
解决方案
我会这样处理它:
$info = '{"ioc":true,"sid":3702088,"ci":3508,"cp":{"id":93006,"t":102,"s":true},"pr":25000,"whid":31472}';
$dec = json_decode($info, true); // true converts to an associative PHP array
echo "ci: " . $dec["ci"] . "<br>";
echo "whid: " . $dec["whid"];
输出:
ci: 3508
whid: 31472
推荐阅读
- gnuplot - 如何在 gnuplot 中使用 `set term push` 和 `set term pop`
- google-apps-script - 列出云端硬盘的内容(不超过配额)
- amazon-dynamodb - Botocore 引发 OSError: [errno 14] 错误地址
- reactjs - React-admin 在创建视图提交后保留表单数据
- python - 我正在尝试通过使用分隔符拆分列值来获取第 n 个空间值
- sql - Oracle查询以获取数据类型的最小值或最大值
- android - 如何在 AOSP 构建中隐藏已安装的应用程序?
- flutter - 有没有办法向地图的 Mapbox 添加自定义图标?
- javascript - 根据事件更改与 dom 相关的元素
- keras - 如何在keras的GRU末尾添加Cov2D