如何从数组中删除特定元素

时间:2010-12-22 09:50:15

标签: php arrays

我有以下数组:

Array
(
    [userid] => 1
    [alias] => rahul
    [firstname] => rahul
    [lastname] => Khan2
    [password] => Ý2jr™``¢(E]_Ø=^
    [email] => salman@gmail.com
    [url] => 4cfe07dbf35d6.jpg
    [avatar_url] => 4cfe07efd2e1c.jpg
    [thumb] => 4cfe07ebc8955.jpg
    [crop_url] => 4cfe07dbf35d6.jpg
    [crop_position] => [100,100,200,200]
    [updatedon] => 0000-00-00 00:00:00
    [createdon] => 0000-00-00 00:00:00
)

我想删除元素url和crop_url我如何从数组中删除它们。

2 个答案:

答案 0 :(得分:6)

unset($array['url'],$array['crop_url']);

答案 1 :(得分:1)

使用unset

unset($arrayname['url']);