找回密码
 立即注册
即日起,论坛关闭新用户注册和登录,论坛相关的贴子保留查阅和下载。获得授权后,有技术问题可联系微信 13199509559 一对一解决。 2024-3-12
查看: 1233|回复: 0
打印 上一主题 下一主题

PHP CURL把json转成数组

209

主题

209

主题

209

主题

管理员

Rank: 9Rank: 9Rank: 9

积分
0
跳转到指定楼层
1#
 楼主| admin 发表于 2023-3-15 13:45:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. $url = '';

  2. $ch = curl_init($url);  
  3. curl_setopt($ch,CURLOPT_ENCODING ,'gb2312');
  4. curl_setopt($ch, CURLOPT_TIMEOUT, 10);  
  5. curl_setopt($ch, CURLOPT_FAILONERROR, false);
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  7. curl_setopt($ch, CURLOPT_HEADER, false);
  8. $result = curl_exec($ch);  
  9. curl_close($ch);  
  10. $result = json_decode($result,true);
  11. print_r($result);


复制代码
重点
  1. curl_setopt($ch, CURLOPT_FAILONERROR, false);
  2. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  3. curl_setopt($ch, CURLOPT_HEADER, false);
复制代码


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表