从数组中删除线[复制]

时间:2022-06-06 21:30:37

Possible Duplicate:
PHP: How to remove specific element from an array?

可能的重复:PHP:如何从数组中删除特定的元素?

How can i remove a line from an array where the key name = a given target...such as

我如何从一个数组中删除一个键名=一个给定的目标…如

[name] => super [price] => 65.87 [quantity] => 25 [addtocart] => 1

say i wanted to remove the [addtocart] => 1 part

假设我想删除[addtocart] => 1部分

2 个解决方案

#1


3  

I believe you want to unset($arr['addtocart']);

我相信你想要解开($arr['addtocart']);

#2


2  

$vars = array('name' => super, 'price' => 65.87, 'quantity' => 25, 'addtocart' => 1);

unset($vars['addtocart']);

#1


3  

I believe you want to unset($arr['addtocart']);

我相信你想要解开($arr['addtocart']);

#2


2  

$vars = array('name' => super, 'price' => 65.87, 'quantity' => 25, 'addtocart' => 1);

unset($vars['addtocart']);