0

我已经打印了 json 数组,它看起来像:

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)

我如何从需要的数组中获取信息,例如:0 -> interp?

4

1 回答 1

2

不要过多地阅读 json。它是一种数据封装格式。你不处理“json数组”。没有这样的事情。有一个 json STRING,您可以将其解码为本机数据结构。例如

$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'];
于 2013-04-03T16:05:44.980 回答