これは、PHParray_search
関数を使用してそれを行うことです。
$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
またはより簡単な方法:
$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
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加