2012-03-06 98 views
2

在PHP當我做腓陣列輸出混亂

var_dump($galleryCategoriesThumb); 

輸出是

array(1) { 


[0]=> 
    array(1) { 
    ["Gallery"]=> 
    array(3) { 
     ["id"]=> 
     string(3) "190" 
     ["photofile"]=> 
     string(6) "50.jpg" 
     ["gallery_category_id"]=> 
     string(2) "58" 
    } 
    } 
} 

當我

var_dump($galleryCategoriesThumb["photofile"]); 

我得到NULL輸出。我也嘗試過其他各種選擇。 我想要做的就是echo [「photofile」]。請幫忙。

回答

3

儘量$galleryCategoriesThumb[0]['Gallery']["photofile"]

+1

它工作。非常感謝你。 – nepalipunk 2012-03-08 04:23:10

1

嘗試var_dump($galleryCategoriesThumb[0]["Gallery"]["photofile"]);

這是一個三維數組。

+1

它的工作。非常感謝你。 – nepalipunk 2012-03-08 04:20:23

1

預期的var_dump($ galleryCategoriesThumb [ 「photofile」]),因爲 「photofile」 鍵並不在$ galleryCategoriesThumb存在返回NULL。

要訪問「photofile」,你需要的陣列中的「完整路徑」爲他人發佈

var_dump($galleryCategoriesThumb[0]["Gallery"]["photofile"]);. 
+0

非常感謝您的解釋。 – nepalipunk 2012-03-08 04:20:12