I've seen a lot of people do the former, is there any performance benefit doing one vs the other? Or is it just an eye candy? I personally use the latter every time as it is shorter and personally more readable to me.
Join them; it only takes a minute:
|
The other responses focus on the differences between the two functions. This is true, but if the source array does not contain
Which gave me the following results: For a small array:
For a relative big array:
So if it's possible it's faster to use |
|||||||||||||
|
|
|||||
|
A much faster alternative to check whether a key exists in an array is to use |
||||
|
They both are different
whereas
|
|||
|