Let's talk about whether the PHP checks whether there is a value in_array function in the array, and talk about in_array. Let's talk about whether a value in_array function exists in the PHP check array, and talk about whether a value exists in the in_arrayPHPin_array () function check array. If yes, return TRUE, otherwise, we will discuss whether the PHP checks whether a value of in_array function exists in the array and the in_array function.
The PHP in_array () function checks whether a value exists in the array. If yes, TRUE is returned; otherwise, FALSE is returned.
Syntax:
bool in_array( mixed needle, array array [, bool strict] )
Parameter description:
Parameters |
Description |
Needle |
The value to be searched in the array. if it is a string, it is case sensitive. |
Array |
Array to be retrieved |
Strict |
Optional. If this parameter is set to TRUE, the needle and array value types are checked. |
Example:
<? Php $ arr_a = array ("a", "B", "c", 1); if (in_array ("a", $ arr_a )) {echo 'character a exists in the $ arr_a array';} else {echo 'character a does not exist in the $ arr_a array';}?>
The output result is as follows:
For example, if character a is strictly checked in the $ arr_a array:
<? Php $ arr_a = array ("a", "B", "c", 1); if (in_array ("1", $ arr_a, TRUE )) {echo 'character 1 exists in the $ arr_a array';} else {echo 'character 1 does not exist in the $ arr_a array';}?>
The output result is as follows:
Character 1 does not exist in the $ arr_a array as a needle example:
<? Php $ arr_a = array ("a", "B"), 1, 2); $ arr_ B = array ("a", "B "); if (in_array ($ arr_ B, $ arr_a) {echo 'array $ arr_ B exists in $ arr_a array ';} else {echo 'array $ arr_ B does not exist in $ arr_a array';}?>
The output result is as follows:
Array $ arr_ B exists in the $ arr_a array
The above discussion about whether the in_array function exists in the PHP check array is all the content shared by the editor. I hope you can provide a reference and support for the help house.
The in_array function checks whether a value exists in the array by using the in_array PHP in_array () function. If yes, return TRUE; otherwise, return...