How does an array search be case insensitive?
Why the following 2 are not searched Ah, I read the manual said add a false can, why not yet?
PHP Code
------Solution--------------------
If needle is a string, the comparison is case-sensitive.
If the value of the third parameter strict is TRUE then the In_array () function also checks whether the needle type is the same as in haystack.
------Solution--------------------
In_array
Optional. If set to true, checks whether the searched data is the same as the type of the array's value.
Whether the type of the value is the same is not case-sensitive
Array_search
If the third parameter, strict, is specified as true, the key name of the corresponding element is returned only if the data type and value are consistent.
is also a type and value, and does not mention case-sensitive things.
According to your needs
1. Traversal using a string comparison function
2. Regular
3. Convert all to lowercase after comparison
....
------Solution--------------------
The third parameter is the type of judgment, which is the use of = = =, not = =.
A function to traverse the line.
------Solution--------------------
Trouble yourself to see php.net, this basic problem you will meet hundreds of thousands, you ask?
------Solution--------------------
Explore
Reference:
If needle is a string, the comparison is case-sensitive.
If the value of the third parameter strict is TRUE then the In_array () function also checks whether the needle type is the same as in haystack.
I would like to ask under what circumstances is the In_array function case insensitive?
I change to an array or case-sensitive.
$DR =array (' cc ', ' Dd ', ' Ee ');
$VR =arr ...
------Solution--------------------
Just write one yourself.
PHP Code
$DR = Array (' CC ', ' dd ', ' Ee '), if (In_iarray ("Dd", $dr, False)) { echo "AA";} function In_iarray ($needle, $haystack, $strict =false) { if (! is_string ($needle)) return In_array ($needle, $ haystack, $strict); Return In_array (Strtolower ($needle), Array_map (' Strtolower ', $haystack));}