doushi8599 2016-11-24 11:20
浏览 957
已采纳

使用file_get_contents从url获取JSON

I have a server that provide some data in JSON. I tried to get these data with the usual:

$res = file_get_contents($url);
$result = json_decode($res);
var_dump($result);

But $result is yet a string. The problem is that the data that comes from file_get_content has some alphanumerical string before data and a zero after.

something like:

215ba
{"@attributes":{"ticker":"FCA"},"info...... // here all json data
0

I already checked json validity directly from the url and it's properly formatted, I can not understand where zero and 215ba come from.

Obviously I could strip the strings eliminating both but I was wondering if there was a more concrete solution instead of a workaround

PS: unfortunately I can not use cURL

  • 写回答

3条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 如何抓这个函数的包wx.updateShareMenu
      • ¥15 需要数据分析!时间紧!
      • ¥15 关于免费论文查重系统的问题。
      • ¥15 朋友们,这个sim函数是出了什么问题了呢
      • ¥15 【MRT数据导入问题】MRT处理modis数据提示opening input header file怎么解决?
      • ¥15 嵌入式系统综合设计题有会的教一下嘛?
      • ¥15 yolov5转onnx验证出错
      • ¥15 proteus仿真LCD不点亮
      • ¥15 C语言红绿灯时间问题
      • ¥15 matlab仿真实现定位算法