$food = array('fruits' => array('orange', 'banana', 'apple'),
                            'veggie' => array('carrot', 'collard', 'pea'));              // recursive count
              echo count($food, COUNT_RECURSIVE); // output 8
怎么是输出8的呢?不是6么?

解决方案 »

  1.   

    COUNT_RECURSIVE   字面意思就是递归统计啊……If the optional mode parameter is set to COUNT_RECURSIVE (or 1), count() will recursively count the array.顺着手册的意思理解吧,,,如果你的需求不适用,自写函数咯,
      

  2.   

    你是要统计数组的元素个数吗?把 echo count($food, COUNT_RECURSIVE);改成 echo count($food, 1);就可以了
      

  3.   

    COUNT_RECURSIVE不是等于1吗?
    ‘If the optional $mode parameter is set to COUNT_RECURSIVE (or 1), count(3) will recursively count the array’
      

  4.   

    本帖最后由 xuzuning 于 2012-07-31 06:44:51 编辑