This is to do it using PHP array_search
function:
$families = session()->pull('families', []);
if(($key = array_search($deleteID, $families)) !== false) {
unset($families[$key]);
}
session()->put('families', $families);
// PS: specify index you want to remove on $deleteID variable
or more simple way:
$index = 0; // let's say it's index 0
$families = Session::get('families'); // save the array
unset($families[$index]); // remove value from array based on index
Session::put('families', $families); // set the array again
// PS: specify index you want to remove on $index variable
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.