I try to use methods in https://laravel.com/docs/9.x/helpers instead of old php functions I used for many year. I did not find any laravel method like in_array.
I tried to use Str::contains , but failed it. Seems different ?
So any replacement of in_array ?
Thanks in advance!
Using
in_arrayseems perfectly acceptable and if it gets the job done for you and is not causing issues then stick with it.That aside, there is the
Arr::has()helper, or alternatively, you could convert your array to a collection and then use thecontains()method, however that just usesin_arraybehind the scenes anyway.