This article mainly introduces the use of PHPin_arrayfunctionchecks whether a certain value exists in thearray, and analyzes the function of the in_array function in more detail. Definitions and related usage skills andNoteshave certain reference value. Friends in need can refer to it
The example in this article describes how PHP uses the in_array function to check whether a certain value exists in the array. Methods. Share it with everyone for your reference. The specific analysis is as follows:
PHP uses the in_array() function to check whether a certain value exists in the array. If it exists, it returns TRUE, otherwise it returns FALSE. It is very easy to use. Let me introduce in_array() in depth. ) Function.
Recently when writing a piece of code in PHP, I need to use it to determine whether a certain value is in another set of values. The in_array function is used to check whether a certain value exists in the array. It is rather vague to understand directly through concepts, and its function can be understood through specific examples.
The syntax is as follows:
bool in_array( mixed needle, array array [, bool strict] )
Parameter description:
Parameter | Explanation |
---|---|
needle | Need tosearch the value ofin the array, if it is astring, differentiate Case |
array | Array to be retrieved |
strict | Optional, if set to TRUE, the value types in needle and array will also be checked |
Example
"; } else { echo "匹配未找到
"; } if (in_array("Mark",$people, TRUE)) { echo "匹配已找到
"; } else { echo "匹配未找到
"; } if (in_array(23,$people, TRUE)) { echo "匹配已找到
"; } else { echo "匹配未找到
"; } ?>
The above is the detailed content of php in_array function checks whether a certain value exists in the array. For more information, please follow other related articles on the PHP Chinese website!