早睡早起,方能养生
Sleep early rise early, way to keep healthy

PHP函数 —— in_array()

super
2020-09-27 17:09
views 2813

 in_array

in_array — 检查数组中是否存在某个值 (PHP4,PHP5,PHP7

in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] ) : bool


 Parameters

needle 待搜索的值(若为字符串,区分大小写)。

haystack 待搜索的数组。

strict 如果为 true ,则会检查 needle 的类型是否和 haystack 中的相同。


 Return Values

TRUE / FALSE


 Examples

$needle = '';
$needle_2 = 0;
$array = [0, 1, 2, 3];

in_array($needle, $array, true); // return FALSE;
in_array($needle_2 , $array, true); // return TRUE;

in_array($needle, $array); // return TRUE;
in_array($needle_2 , $array); // return TRUE;





分享
0 条讨论
top