PHP searches the array for a given simple instance of the Array_search function, array array_search
Array_search ()
The PHP Array_search () function is used to search the array for the given value, and if successful returns the corresponding key name, otherwise FALSE.
Grammar:
Mixed Array_search (mixed needle, array array [, BOOL strict]) parameter description:
| Parameters |
Description |
| Needle |
The value that needs to be searched in the array, if it is a string, is case-sensitive |
| Array |
The array to retrieve |
| Strict |
Optional, if set to TRUE, the value types in the needle and array are also checked |
Because the index array may have a starting index number of 0, the function may also return a non-Boolean value equivalent to FALSE, such as 0 or "", so you need to use the = = = operator to rigorously validate the value returned by the function.
Example:
<?php$arr_a = Array (0 = "a", 1 = "B", 2 = "C"), $key = Array_search ("A", $arr _a), if ($key!== FALSE) { E Cho "Key name: $key";} else { echo ' no match result ';}? >
The example output is as follows:
Key Name: 0 if needle occurs more than once in an array, the first matching key is returned. To return all keys that match a value, use the Array_keys () function.
The above PHP in the array to search for a given simple instance array_search function is the small part of the whole content to share to everyone, I hope to give you a reference, but also hope that we have a lot of support to help the home.
http://www.bkjia.com/PHPjc/1136642.html www.bkjia.com true http://www.bkjia.com/PHPjc/1136642.html techarticle PHP searches the array for a given simple instance of the Array_search function, the array array_search array_search () PHP Array_search () function is used to search the array for a given value, and if successful then return ...