How to unset (remove) a collection element after fetching it?

后端 未结 5 1417
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 18:28

I have a collection which I want to iterate and modify while I fetch some of its elements. But I could\'t find a way or method to remove that fetched element.



        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 18:56

    You would want to use ->forget()

    $collection->forget($key);
    

    Link to the forget method documentation

提交回复
热议问题