Answer the question
In order to leave comments, you need to log in
Is there an analogue of array_search in laravel collections?
Good afternoon.
In collections, I found only the contains method, which returns true if the element was found in the collection or false if it was not found. And I need a method that, if an element is found, would return the key of this array. I leafed through the documentation on collections several times - but I didn’t find anything suitable, except perhaps .each, but this will have to be written a lot of extra if there is still an analogue of array_search.
Answer the question
In order to leave comments, you need to log in
I solved it using the ->where() method. In two-dimensional arrays, apparently, this is the only option. Although it’s quite convenient .. Thank you all)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question