php in_array() function


  Translation results:

英[əˈreɪ] 美[ə'reɪ]

n.Array; queue, array; a large number; clothes

vt. Arrange; deploy troops; dress up, decorate

Third person singular: arrays Plural: arrays Present participle: arraying Past tense: arrayed Past participle: arrayed

php in_array() functionsyntax

Function: Search whether the specified value exists in the array

Syntax: in_array(search,array,type)

Parameters:

ParametersDescription
search Required. Specifies the value to search for in the array.
arrayRequired. Specifies the array to search.
typeOptional. If this parameter is set to true, it is checked whether the type of the searched data and the value of the array are the same.

Note: If the search parameter is a string and the type parameter is set to TRUE, the search is case-sensitive.

php in_array() functionexample

<?php
$people = array("西门", "中文网", "灭绝", "无忌");
if (in_array("西门", $people))
{
    echo "已找到";
}
else
{
    echo "未找到";
}
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

已找到

Home

Videos

Q&A