我想删除1个数组Session::push('product', $array);
例如:当点击按钮删除(x)时,会话将删除数组[0]和Session::push('product', $array);
只是仍然数组[1]
"product" => array:1 [▼
0 => array:5 [▼
"id" => "9"
"name" => "Điện thoại Samsung Galaxy A5 2016"
"price" => "888888990"
"picture" => "16046_315945335227228_2087086595407127217_n.jpg"
"qty" => "1"
]
1 => array:5 [▼
"id" => "10"
"name" => "Điện thoại Samsung Galaxy A5 2016"
"price" => "888888990"
"picture" => "16046_315945335227228_2087086595407127217_n.jpg"
"qty" => "1"
]
]
答案 0 :(得分:0)
<?php
// Get the product array
$product = Session::get('product');
// Unset the first index (or provide an index)
unset($product[0]);
// Overwrite the product session
Session::put('product', $product);