php in_array function checks whether a certain value exists in the array

怪我咯
Release: 2023-03-14 07:52:01
Original
1608 people have browsed it

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] )
Copy after login

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 "匹配未找到
"; } ?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!