用逗号分隔值获取多维数组中的条目数 - php

时间:2017-02-01 05:28:26

标签: php arrays codeigniter

如何获取下面数组中的条目数?

我尝试Count arrays comma separated values并没有得到理想的解决方案。请建议一种方法。

以下样本数为11。

$sample= Array ( 
[0] => Array ( 
             [0] => Array ( [attendance] => 2012SD71,2010SD94 ) 
             [1] => Array ( [attendance] => 2003SD18,2003SD19 ) 
             [2] => Array ( [attendance] => 2003SD23,2003SD28 )) 
[1] => 
[2] => 
[3] => 
[4] => 
[5] => 
[6] => 
[7] => 
[8] => 
[9] => 
[10] => 
[11] => 
[12] => 
[13] => Array ( 
              [0] => Array ( [attendance] => 2012SD81,2010SD84 ) 
              [1] => Array ( [attendance] => 2003SD18,2003SD19,2004SD14 ) ) [14] => 
[15] =>
 );

1 个答案:

答案 0 :(得分:2)

一个简单的递归函数应该可以使用controllers/devise/explode()

array_merge()