男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站

in_array

(PHP 4, PHP 5, PHP 7, PHP 8)

in_array檢查數組中是否存在某個(gè)值

說(shuō)明

in_array(mixed $needle, array $haystack, bool $strict = false): bool

大海撈針,在大海(haystack)中搜索針( needle),如果沒(méi)有設置 strict 則使用寬松的比較。

參數

needle

待搜索的值。

注意:

如果 needle 是字符串,則比較是區分大小寫(xiě)的。

haystack

待搜索的數組。

strict

如果第三個(gè)參數 strict 的值為 truein_array() 函數還會(huì )檢查 needle類(lèi)型是否和 haystack 中的相同。

返回值

如果找到 needle 則返回 true,否則返回 false。

范例

示例 #1 in_array() 例子

<?php
$os 
= array("Mac""NT""Irix""Linux");
if (
in_array("Irix"$os)) {
    echo 
"Got Irix";
}
if (
in_array("mac"$os)) {
    echo 
"Got mac";
}
?>

第二個(gè)條件失敗,因為 in_array() 是區分大小寫(xiě)的,所以以上程序顯示為:

Got Irix

示例 #2 in_array() 嚴格類(lèi)型檢查例子

<?php
$a 
= array('1.10'12.41.13);

if (
in_array('12.4'$atrue)) {
    echo 
"'12.4' found with strict check\n";
}

if (
in_array(1.13$atrue)) {
    echo 
"1.13 found with strict check\n";
}
?>

以上例程會(huì )輸出:

1.13 found with strict check

示例 #3 in_array() 中用數組作為 needle

<?php
$a 
= array(array('p''h'), array('p''r'), 'o');

if (
in_array(array('p''h'), $a)) {
    echo 
"'ph' was found\n";
}

if (
in_array(array('f''i'), $a)) {
    echo 
"'fi' was found\n";
}

if (
in_array('o'$a)) {
    echo 
"'o' was found\n";
}
?>

以上例程會(huì )輸出:

  'ph' was found
  'o' was found

參見(jiàn)

  • array_search() - 在數組中搜索給定的值,如果成功則返回首個(gè)相應的鍵名
  • isset() - 檢測變量是否已聲明并且其值不為 null
  • array_key_exists() - 檢查數組里是否有指定的鍵名或索引

男女疯狂一边摸一边做羞羞视频|啊好深好硬快点用力别停动态图|亚洲一区无码中文字幕|特级无码毛片免费视频播放▽|久久狠狠躁免费观看|国内精品久久久久久网站