douyimin1083 2013-04-03 16:03
浏览 22
已采纳

我如何从json数组中获取所选信息?

i have printed json array, it loks like:

array (size=1)
  '2013-04-02' => 
    array (size=13)
      0 => 
        array (size=8)
          'date' => string '2013-04-02' (length=10)
          'sign' => int 0
          'slant' => string 'Generic' (length=7)
          'rating' => int 3
          'interp' => string 'We are eager to bring excitement into our lives today but other obligations prevent us from acting irresponsibly. The buzz from all the action-packed Aries planets keeps the energy jumping, but the Moon trudges into emotionally resistant Capricorn at 1:35 am EDT to set a serious tone to the day as we go about our business. Meanwhile, we can feel the weight of stern Saturn pushing away pleasure as it forms a difficult aspect with sweet Venus.' (length=445)
          'sms_interp' => string '' (length=0)
          'keyword' => string 'obligations' (length=11)
          'subject_line' => string 'We are eager to bring excitement into our lives ...' (length=51)
      1 => 
        array (size=8)
          'date' => string '2013-04-02' (length=10)
          'sign' => int 1
          'slant' => string 'Generic' (length=7)
          'rating' => int 2
          'interp' => string 'You are growing tired of your current responsibilities and are ready for a change of pace. You feel as if you have been working hard enough and now you are eager to take a break. Unfortunately, you may have to put off the fun and games a while longer while you fulfill the promises you already made to yourself and others. Thankfully, you'll really be able to let loose once you don't have unfulfilled obligations still hanging over your head.' (length=443)
          'sms_interp' => string '' (length=0)
          'keyword' => string 'commitments' (length=11)
          'subject_line' => string 'You are growing tired of your ...' (length=33)

How i can get information from needful array, for example: 0 -> interp?

  • 写回答

1条回答 默认 最新

  • doucheng2053 2013-04-03 16:05
    关注

    Don't read too much into json. it's a data encapsulation format. You don't deal with a "json array". There's no such thing. There's a json STRING, which you decode into a native data structure. e.g.

    $json = "... your raw json text here ...";
    $data = json_decode($json, true); // true to force an array, instead of object.
    
    echo $data['2013-04-02'][0]['interp'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算