private function delete_read($id)
{
$unread = unserialize(Auth::user()->unread);
if (in_array($id, $unread))
{
$new = array_where($unread, function ($key, $value) {
return $value != $id;
});
dd($new);
}
}
I'm trying to delete read post from an unread posts list. The above codes give me an Undefined variable: id error, which refers to this line of code: return $value != $id;
So my question is how to pass variables into array_where method?
BTW, is there any better way to delete given elements from an array, other than unset? Or would unset be better than my array_where approach?
Thanks.