string(2) "15"   [24]=>   string(2) "10"/>   string(2) "15"   [24]=>   string(2) "10">
Home > Backend Development > PHP Tutorial > PHP 删除数组,该如何解决

PHP 删除数组,该如何解决

WBOY
Release: 2016-06-13 10:26:28
Original
884 people have browsed it

PHP 删除数组
var_dump($array_cart);

array(5) {
  [1]=>
  string(1) "3"
  [5]=>
  string(2) "15"
  [24]=>
  string(2) "10"
[16]=>
string(4) "5888"
  [7]=>
  string(1) "1"
}

删除


怎么删除 [16]=>
  string(4) "5888" 这个数组啊

------解决方案--------------------
你可能没描述清楚吧

删数组元素unset($arr[下标]) 即可,是不是和你的超链接里id=16有关?
------解决方案--------------------
$id = (int)$_GET['id'];
unset($array_cart[$id]);

注意函数内要引用传递

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template