Php 调用未定义的函数splice()

Php 调用未定义的函数splice(),php,arrays,session,splice,Php,Arrays,Session,Splice,我想取消设置会话数组,并删除数组的索引 $productno = $_GET['productno']; unset($_SESSION['cart'][$productno]); $_SESSION['cart'].array_splice(index, $productno); 错误:致命错误:调用未定义的函数 上述代码中有什么错误使用:阵列拼接 array_splice($_SESSION['cart'], $index, $productno); 这不是JavaScript,在P

我想取消设置会话数组,并删除数组的索引

$productno = $_GET['productno'];

unset($_SESSION['cart'][$productno]);

$_SESSION['cart'].array_splice(index, $productno);
错误:致命错误:调用未定义的函数

上述代码中有什么错误使用:阵列拼接

array_splice($_SESSION['cart'], $index, $productno);

这不是JavaScript,在PHP中没有名为splice的函数,甚至不能对字符串调用方法。你可能正在寻找这个函数:仍然是错误的…更新答案为什么否决投票?有什么问题吗?
$productno = $_GET['productno'];

unset($_SESSION['cart'][$productno]);


$cart = $_SESSION['cart'];
$_SESSION['cart'] = array_splice($cart, $productno);