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 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序