2015-05-15 69 views
0

我有以下的數組:從數組中取出的索引

array(3) { 
    [0]=> array(1) { ["theme_loader_plugin"]=> string(4) "_run" } 
    [1]=> array(1) { ["user_plugin"]=> string(4) "_run" } 
    [2]=> array(1) { ["sessions_plugin"]=> string(4) "_run" } 
} 

有一種方法使用預定義的PHP函數以去除索引和代替格式化這樣的:通過

array(3) { 
    ["theme_loader_plugin"]=> string(4) "_run", 
    ["user_plugin"]=> string(4) "_run", 
    ["sessions_plugin"]=> string(4) "_run" 
} 
+0

直接array_keys通過@ Rizier123 –

回答

2

環路該數組並將它們合併到新數組。希望這將有助於 -

$arr = array( 
    array("theme_loader_plugin"=> "_run") , 
    array("user_plugin"=> "_run") , 
    array("sessions_plugin"=> "_run") 
) ; 

$new= array(); 
foreach($arr as $val) { 
    $new = array_merge($new, $val); 
} 

輸出

array(3) { 
    ["theme_loader_plugin"]=> 
    string(4) "_run" 
    ["user_plugin"]=> 
    string(4) "_run" 
    ["sessions_plugin"]=> 
    string(4) "_run" 
} 
+1

thnks的建議獲取所有,但我一直在尋找一個預定義的PHP函數。我會接受它的壽命。 –

+1

你必須爲此做一些技巧。 –