首页 > 解决方案 > 如何获得这个值

问题描述

如何获取350831472从中获取:

$info = {"ioc":true,"sid":3702088,"ci":3508,"cp":{"id":93006,"t":102,"s":true},"pr":25000,"whid":31472}

我使用json_decode,但结果是:

“未捕获的错误:stdClass 类的对象无法转换为字符串......”

标签: php

解决方案


我会这样处理它:

$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

推荐阅读