dsh1956 2017-04-09 08:18
浏览 35

在curl中获取指定数组

i get some data with curl from web service and here is my curl code:

$uri="http://test.com";
$ch=curl_init($uri);
curl_setopt_array($ch,array(
CURLOPT_HTTPHEADER=>array('shopid:691','device:2'),
CURLOPT_RETURNTRANSFER=>true
));
$out=curl_exec($ch);
curl_close($ch);
$obj=json_decode($out,true);
print_r($obj);

and my curl out put:

{
  "p":
    "Serial": "b216"
  },
  "review": {
    "Review": "<div dir=\"rtl\">test</div>
"
  },
  "likes": 2,
  "brand": {
    "Name": "test"
  },
  "followers": [],
  "Shop": null
}

i want to get "b216" value in array "p" but i cannot get the value with print_r or echo $obj[0] or echo $obj[0]['Serial']

anyone know how to get this data?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用
    • ¥15 C++ yoloV5改写遇到的问题
    • ¥20 win11修改中文用户名路径
    • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法