Skip to content
Advertisement

PHP case-insensitive in_array function

Is it possible to do case-insensitive comparison when using the in_array function?

So with a source array like this:

JavaScript

The following lookups would all return true:

JavaScript

What function or set of functions would do the same? I don’t think in_array itself can do this.

Advertisement

Answer

you can use preg_grep():

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement