久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php 怎么循環(huán)數(shù)組取有值的

      php 怎么循環(huán)數(shù)組取有值的

      php 怎么循環(huán)數(shù)組取有值的

      1、使用foreach或者while的,利用這兩個語法結(jié)構(gòu)來輸出有值的項或刪除數(shù)組中的空元素,簡單代碼如下:

      <?php foreach( $arr as $k=>$v){     if( $v ){         echo $arr[$k];     }else{         // unset( $arr[$k] );     } } ?>

      foreach是將當(dāng)前操作的數(shù)組進(jìn)行copy,每操作一下foreach,都是copy了一個變量,頁面里面如果有太多的foreach,會是一個很大的消耗。

      2、使用array_filter函數(shù),功能是利用回調(diào)函數(shù)來對數(shù)組進(jìn)行過濾,如果沒有回調(diào)函數(shù),那么默認(rèn)就是刪除數(shù)組中值為false的項目。

      <?php    $entry = array(                 0 => 'foo',                 1 => false,                 2 => -1,                 3 => null,                 4 => ''             );    print_r(array_filter($entry));    ?>

      輸出值為:

      Array    (        [0] => foo        [2] => -1    )

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