I have an array like this:
$array = Array ( 0 => 'oooo', 1 => 'no', 2 => 'mmmm', 3 => 'yes' );
I'd like to search for a word "yes". I know about array_search()
, but I'd like to match "yes", "Yes" and "YES" as well.
How can I do this?
Yes, the String. indexOf() methods are all case-sensitive.
The in_array() function searches an array for a specific value. Note: If the search parameter is a string and the type parameter is set to TRUE, the search is case-sensitive.
case insensitive (not comparable) (computer science) Treating or interpreting upper- and lowercase letters as being the same.
array_search(strtolower($search), array_map('strtolower', $array));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With