This article mainly introduces PHP using the In_array function to check if there is a value in the array, a more detailed analysis of the function of the In_array function, definition and related use of skills and considerations, with a certain reference value, the need for friends can refer to the next
This example describes how PHP uses the In_array function to check if a value exists in an array. Share to everyone for your reference. The specific analysis is as follows:
PHP uses the In_array () function to check if a value exists in the array, return TRUE if it exists, or return false, which is very useful, and I'll dive into the In_array () function for you.
When writing a piece of code in PHP recently, it is used to determine whether a value is in another set of values. The In_array function is used to check if a value exists in the array. Directly through the conceptual understanding of the fuzzy, you can use specific examples to understand its role.
The syntax is as follows:
BOOL In_array (mixed needle, array array [, BOOL strict])
Parameter description:
parameter
description |
needle |
The value that needs to be searched in the array, and if it is a string, it is case-sensitive |
array |
array to retrieve |
Strict |
Optional, if set to TRUE, the value types in the needle and array are also checked |
Example
<?php$people = Array ("Bill", "Steve", "Mark", "David"); if (In_array ("23", $ People, TRUE) {echo "match found <br>"; }else {echo "Match not found <br>"; }if (In_array ("Mark", $people, TRUE)) {echo "match found <br>"; }else {echo "Match not found <br>"; }if (In_array ($people, TRUE)) {echo "match found <br>"; }else {echo "Match not found <br>"; }?>