doujianwei8217 2018-08-10 04:26
浏览 46
已采纳

TMDB PHP结果数组

I use code in PHP for get info about season. How I can get result in array?? Thanks.

Doc TMDB

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.themoviedb.org/3/tv/xxx/season/xxx?language=en-US&api_key=xxx",

$response = curl_exec($curl);
 echo $response;
  • 写回答

1条回答 默认 最新

  • dsh1956 2018-08-10 07:16
    关注

    Your expected result seems to be a JSON-object, according to the documentation you linked - so echo won't work. Use var_dump(json_decode($response)); to see the result.

    If you want to work with the JSON-object in PHP you will have to "cast" it to a PHP-object:

    $newObject = json_decode($response);
    

    You can than access the objects properties in PHP like so:

    echo $newObject->id;
    echo $newObject->name;
    

    etc.. See the PHP documentation on this topic here: PHP - json-decode

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号