PHP searches for the given simple instance array_search function in the array, array array_search. PHP searches for the given simple instance array_search function in the array. the array array_searcharray_search () PHParray_search () function is used to search for the given value in the array, if it succeeds, return to PHP to search for the given simple instance array_search function in the array, array array_search
Array_search ()
The PHP array_search () function is used to search for a given value in the array. if the value is successful, the corresponding key name is returned. otherwise, FALSE is returned.
Syntax:
Mixed array_search (mixed needle, array [, bool strict]) parameter description:
Parameters |
Description |
Needle |
The value to be searched in the array. if it is a string, it is case sensitive. |
Array |
Array to be retrieved |
Strict |
Optional. If this parameter is set to TRUE, the needle and array value types are checked. |
Because the starting index number of the index array may be 0, this function may return non-Boolean values equivalent to FALSE, such as 0 or "", therefore, you must use the = operator to strictly verify the value returned by the function.
Example:
<? Php $ arr_a = array (0 => "a", 1 => "B", 2 => "c"); $ key = array_search ("", $ arr_a); if ($ key! = FALSE) {echo "key name: $ key";} else {echo 'no matching result';}?>
The output result is as follows:
Key name: 0 if needle appears more than once in array, the first matched Key is returned. To return keys of all matched values, use the array_keys () function.
The above PHP search for the given simple instance array_search function in the array is all the content shared by the editor. I hope you can give us a reference and support for the help house.
The http://www.bkjia.com/PHPjc/1136642.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1136642.htmlTechArticlePHP searches for the given simple instance array_search function in the array, the array array_search () PHP array_search () function is used to search for the given value in the array, if successful, return...