English [s?:t?] US [s?:rt?]
##v. Search; search, search; investigate; exploren. Search; investigate; exploreThird person singular: search Present participle: searching Past tense: search Past participle: search
php array_search() function syntax
Function: Search for a key value in the array and return the corresponding key name.
Syntax: array_search(value,array,strict)
Parameters:
Parameter | Description |
value | Required. Specifies the key value to be searched. |
array | Required. Specifies the array to be searched. |
strict | Optional. If this parameter is set to TRUE, the function searches the array for elements of the same data type and value. Possible values: true, false - default, if set to true, the type of the given value is checked in the array, the number 5 and the string 5 are different |
Description: Search for a key value in the array. If the value is found, the key name of the matching element will be returned. If not found, returns false.
php array_search() function example
<?php $a=array("a"=>"西門","b"=>"php中文網(wǎng)","c"=>"php.cn"); echo array_search("西門",$a); ?>
Run instance?
Click the "Run instance" button to view the online instance
Output:
a
<?php $a=array("1"=>"滅絕","2"=>"歐陽克","3"=>"php.cn"); echo array_search("歐陽克",$a); ?>
Run instance?
Click the "Run instance" button to view the online instance
Output:
2