2010-10-29 52 views
0

我有這個陣列中的PHP從數組中刪除元素知道它的名字

array(5) { 
    ["mai_id"] => string(1) "3" 
    ["mai_logo"] => string(0) "" 
    ["mai_title"] => string(16) "Vitrine Cultural" 
    ["mai_description"] => NULL 
    ["mai_description2"] => NULL 
} 

而且我想刪除["mai_description"]並獲得唯一

array(5) { 
    ["mai_id"] => string(1) "3" 
    ["mai_logo"] => string(0) "" 
    ["mai_title"] => string(16) "Vitrine Cultural" 
    ["mai_description2"] => NULL 
} 

有什麼辦法?

回答

4

是啊,用unset()

unset($array['mai_description']); 
+0

哈哈,一個downvote? – 2010-10-29 21:40:42

2
unset($array["mai_description"]); 

應該做的伎倆。

/編輯以修復即使它是同彼得

3
unset($array['mai_description']) 

但使用文件語法錯誤,請。