Array_search () of the php array function sequence-return key name by element value. Array_search () defines and uses the array_search () function and the in_array () function to find a key value in the array. If this value is found, the key name of the matching element is returned. If the definition and usage of array_search () are not found
The array_search () function is the same as the in_array () function. you can find a key value in the array. If this value is found, the key name of the matching element is returned. If not found, false is returned.
Before PHP 4.2.0, the function returns null instead of false in case of failure.
If the third parameter strict is set to true, the key name of the corresponding element is returned only when the data type and value are consistent.
Syntax
Array_search (value, array, strict) parameter description
Value is required. Specifies the value to be searched in the array.
Array is required. The searched array.
Strict is optional. Possible values:
True
False-default
If the value is set to true, the type of the given value is also checked in the array. (See example 2)
Example 1
The code is as follows:
$ A = array ("a" => "Dog", "B" => "Cat", "c" => "Horse ");
Echo array_search ("Dog", $ );
?>
Output:
A
The http://www.bkjia.com/PHPjc/324437.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324437.htmlTechArticlearray_search () defines and uses the array_search () function, like in_array (), to find a key value in the array. If this value is found, the key name of the matching element is returned. If no...