2014-07-03 33 views
0
Array 
(
    [statuses] => Array 
     (
      [0] => Array 
       (
        [metadata] => Array 
         (
          [result_type] => recent 
          [iso_language_code] => en 
         ) 

        [created_at] => Thu Jul 03 08:06:24 +0000 2014 
        [id] => 484609084809687043 
        [id_str] => 484609084809687043 
        [text] => RT @RashtrapatiBhvn: #Rains at the #RashtrapatiBhavan http://t.co/w1imlVFbHe 
        [source] => Twitter Web Client 
        [truncated] => 
        [in_reply_to_status_id] => 
        [in_reply_to_status_id_str] => 
        [in_reply_to_user_id] => 
        [in_reply_to_user_id_str] => 
        [in_reply_to_screen_name] => 
        [user] => Array 
         (
          [id] => 1620882618 
          [id_str] => 1620882618 
          [name] => HinduNationalist#HDL 
          [screen_name] => hinduwarrior15 
          [location] => HINDUSTAN 
          [description] => I want India to become a exclusive Hindurashtra. Want a HINDUSTAN by hindus for hindus and to hindus. HINDU NATIONALIST.. #HDL 
          [url] => http://t.co/hWAAfdlWMX 
          [entities] => Array 
           (
            [url] => Array 
             (
              [urls] => Array 
               (
                [0] => Array 
                 (
                  [url] => http://t.co/hWAAfdlWMX 
                  [expanded_url] => http://www.hdlindia.org/ 
                  [display_url] => hdlindia.org 
                  [indices] => Array 
                   (
                    [0] => 0 
                    [1] => 22 
                   ) 

                 ) 

               ) 

             ) 

這是我從調用Twitter API獲得的典型結果,但我只想顯示其中的id和文本。我已經使用json_decode方法解碼了傳入的json結果。顯示來自JSON解碼陣列的文本

我從來沒有使用JSON字符串,這將是巨大的,如果有人可以幫助

請幫

回答

0

$yourArray['statuses'][0]['id']$yourArray['statuses'][0]['text']應該做的伎倆。

+0

嘿感謝它的工作,但如果我想顯示用戶數組中的文本,如果我想顯示用戶ID –

+0

這些都是嵌套數組。嘗試理解結構並儘可能深入你的需要。 'user'數組也是'$ yourArray ['statuses'] [0]'的一個項目。所以,如果你想從用戶數組中訪問'id',你可以進一步深入一層:''''''''''''''''''''''''''''''''''' – halloei