我有这个部分json:
string(1583) "[{"user_id":"U4qtgydvSgG9zV9F"}]
我如何获得user_id值?
我试过了:
$json = json_decode($res);
$UserId = $res->user_id;
但我没有点击user_id。
然后我尝试将结果转换为数组,访问user_id,如下所示:
$res = (array)file_get_contents($url, false, $context);
echo $res['user_id'];
数组如下所示:
array(1) { [0]=> string(1583) "[{"user_id":"U4qtgydvSgG9zV9F-NB2rQ"
我如何获得user_id值?感谢
答案 0 :(得分:0)
看到这个json示例:
$j = '[{"user_id":"U4qtgydvSgG9zV9F"}]';
$j = json_decode($j);
echo $j[0]->user_id;