English [sɜ:tʃ] US [sɜ:rtʃ]

##v. Search; search, search; investigate; explore

n. Search; investigate; explore

Third 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:

ParameterDescription
valueRequired. Specifies the key value to be searched.
arrayRequired. 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中文网","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