• <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
  • <th id="l3qpx"><progress id="l3qpx"></progress></th>
      <th id="l3qpx"></th>
      <dd id="l3qpx"><font id="l3qpx"></font></dd>
      <th id="l3qpx"></th>
      0712-2888027 189-8648-0214
      微信公眾號

      孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號

      當(dāng)前位置:主頁 > 技術(shù)支持 > PHP > php中獲得數(shù)組長度的方法

      php中獲得數(shù)組長度的方法

      時間:2015-12-24來源:風(fēng)信官網(wǎng) 點擊: 635次
      count — 計算數(shù)組中的單元數(shù)目或?qū)ο笾械膶傩詡€數(shù)
      strlen是統(tǒng)計數(shù)組中元素的長度;

      你如果想統(tǒng)計數(shù)組中所有元素的長度,那就用循環(huán)統(tǒng)計吧

      代碼:
      $a  =  array('0'  =>  '123',  '1'  =>  'asdf');

        $count  =  count($a);

        $a_length  =  0;

        for  ($i=0;  $i<$count;  $i++)  {
        $a_length  =  $a_length  +  strlen($a[$i]);
        }
        print  $a_length;
       


        代碼:
      <?phptqeb
      $a[0]
      ?>

      Example #1 count() 例子
      <?php
      $a[0] = 1;
      $a[1] = 3;
      $a[2] = 5;
      $result = count($a);
      // $result == 3

      $b[0]  = 7;
      $b[5]  = 9;
      $b[10] = 11;
      $result = count($b);
      // $result == 3

      $result = count(null);
      // $result == 0

      $result = count(false);
      // $result == 1
      ?>

      Example #2 遞歸 count() 例子

      <?php
      $food = array('fruits' => array('orange', 'banana', 'apple'),
                    'veggie' => array('carrot', 'collard', 'pea'));

      // recursive count
      echo count($food, COUNT_RECURSIVE); // output 8

      // normal count
      echo count($food); // output 2

      ?>
      熱門關(guān)鍵詞: php 數(shù)組長度
      欄目列表
      推薦內(nèi)容
      熱點內(nèi)容
      展開
      欧美一区二区三区免费A级视频,亚洲精品中文字幕综合,动漫精品中文字幕无码第一页,1024亚洲国产综合 亚太影院 柯西贝尔-游戏赚网
    1. <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
    2. <th id="l3qpx"><progress id="l3qpx"></progress></th>
        <th id="l3qpx"></th>
        <dd id="l3qpx"><font id="l3qpx"></font></dd>
        <th id="l3qpx"></th>