久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php怎么查詢數(shù)組某一個(gè)value是否存在

      查詢是否存在的方法:1、使用in_array()函數(shù),語(yǔ)法“in_array(value值,$array)”;2、使用array_search()函數(shù),語(yǔ)法“array_search(value值,$array)”。

      php怎么查詢數(shù)組某一個(gè)value是否存在

      本教程操作環(huán)境:windows7系統(tǒng)、PHP7.1版、DELL G3電腦

      php查詢數(shù)組某一個(gè)value值是否存在

      方法1:使用in_array()函數(shù)

      in_array() 函數(shù)可以查找數(shù)組中是否包含某個(gè)值,如果存在則返回 TRUE,不存在則返回 FALSE。語(yǔ)法格式如下:

      in_array($needle, $array[, $strict = FALSE])

      參數(shù)說(shuō)明如下:

      • $needle:為待搜索的值,如果 $needle 是字符串,則在比較時(shí)區(qū)分大小寫(xiě);
      • $array:為待搜索的數(shù)組;
      • $strict:為可選參數(shù),默認(rèn)為 FALSE。
        • 如果 $strict 為空或者 FALSE,則 in_array() 函數(shù)只會(huì)檢查 $needle 的值是否和 $array 中的值相等;
        • 如果 $strict 的值為 TRUE,in_array() 函數(shù)除了會(huì)檢查 $needle 和 $array 中的值之外,還會(huì)比較它們的類(lèi)型是否相等。

      示例:

      <?php header("Content-type:text/html;charset=utf-8"); $sites = array("Google", "Taobao", "Facebook"); if (in_array("PHP中文網(wǎng)", $sites)) {     echo "找到匹配項(xiàng)!"; } else {     echo "沒(méi)有找到匹配項(xiàng)!"; } ?>

      php怎么查詢數(shù)組某一個(gè)value是否存在

      方法2:使用array_search()函數(shù)

      array_search() 函數(shù)在數(shù)組中搜索某個(gè)鍵值,如果在數(shù)組中找到指定的鍵值,則返回對(duì)應(yīng)的鍵名,否則返回 FALSE。語(yǔ)法格式如下:

      array_search(value,array,strict)
      • value 必需。規(guī)定在數(shù)組中搜索的鍵值。

      • array 必需。規(guī)定被搜索的數(shù)組。

      • strict 可選。如果該參數(shù)被設(shè)置為 TRUE,則函數(shù)在數(shù)組中搜索數(shù)據(jù)類(lèi)型和值都一致的元素。可能的值:

        • true

        • false – 默認(rèn)

        如果設(shè)置為 true,則在數(shù)組中檢查給定值的類(lèi)型,數(shù)字 5 和字符串 5 是不同的(參見(jiàn)實(shí)例 2)。

      如果在數(shù)組中找到鍵值超過(guò)一次,則返回第一次找到的鍵值所匹配的鍵名。

      示例:

      <?php header("Content-type:text/html;charset=utf-8"); $sites = array("Google", "Taobao", "Facebook"); if (array_search("Taobao", $sites)) {     echo "找到匹配項(xiàng)!"; } else {     echo "沒(méi)有找到匹配項(xiàng)!"; } ?>

      php怎么查詢數(shù)組某一個(gè)value是否存在

      推薦學(xué)習(xí):《PHP視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)