我想显示设置为非空的数组,如果搜索命中空数组然后计数到10仍为空数组然后关闭数组然后继续

时间:2014-09-15 08:37:54

标签: php zend-framework

在下面的数组中我想从数组[0]到数组[2]显示是pack1,数组[5]到数组[10] pack2,数组[10]到数组[12]是pack3 pack4从数组开始[14]。 (如果空数组大于2,则关闭包并启动另一个包)

array
(
 [0] => array
    (
     [id] => 1
     [num] => 980909
    )

 [1] => array
    (
     [id] => 2
     [num] => 090909
    )

 [2] => array
    (
     [id] => 3
     [num] => 909
    )

 [3] => array
    (
    )
 [4] => array
    (
    )
 [5] => array
    (
     [id] => 6
     [num] => 6565
    )
 [6] => array
    (
     [id] => 7
     [num] => 6565
    )
 [7] => array
    (
     [id] => 8
     [num] => 65
    )
 [8] => array
    (
    ) 
 [9] => array
    (
     [id] => 10
     [num] => 665
    )
 [10] => array
    (
     [id] => 11
     [num] => 600
    )
 [11] => array
    (
    ) 
 [12] => array
    (
    ) 
 [13] => array
    (
    ) 
 [14] => array
    (
     [id] => 15
     [num] => 700
    )

1 个答案:

答案 0 :(得分:0)

$ datas = array(); $ empcount = 10; $ emp = $ dIndex = 0;

为($ I = 0; $我   if($ emp> = $ empcount){$ dIndex ++; $ emp = 0; } $ datas [$ dIndex] [] = $ finaldata [$ i]; }