Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the forget () method in the Laravel collection

Shulou Source: shulou.com Published: 2022-06-01 02:16:10 09月29日 Update

This article mainly introduces how to use the forget () method in the Laravel collection, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Forget ()

Forget simply removes the item from the collection. You only need to pass a key and it removes the item from the collection.

$forget = collect (['country' = >' usa', 'state' = >' ny']); $forget- > forget ('country')-> all ()

The response from the above code is as follows:

["state" = > "ny"]

Forget does not apply to multidimensional arrays.

Thank you for reading this article carefully. I hope the article "how to use the forget () method in the Laravel collection" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles methods discomfort code value interest just at the same time arrays more friends knowledge editing industry information information channels projects channels multi-dimensions references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information vpn MySQL Xiaomi Shulou Technology