There is such an array:

$arr = [[0,0,0,0,0][0,0,0,1,1][0,0,0,1,1][0,0,1,1,1][0,0,1,1,1][0,0,0,0,0][0,0,0,0,0][0,0,0,0,0][0,0,1,1,1][0,0,0,1,1][0,0,0,0,1][0,0,0,1,1][0,0,0,0,0][0,0,0,0,0][0,0,0,0,1][0,0,1,0,0][1,1,1,1,1][0,0,0,0,0][0,0,0,0,0]] 

We check each element of the array, if we meet 1, then we write this element to a new array. If the item does not contain 0, then you need to stop recording and continue searching. This should result in the following array:

 [[[0,0,0,1,1][0,0,0,1,1][0,0,1,1,1][0,0,1,1,1]],[[0,0,1,1,1][0,0,0,1,1][0,0,0,0,1][0,0,0,1,1]],[[0,0,0,0,1][0,0,1,0,0][1,1,1,1,1]]] 

I try to do so

 for ($n = 0; $n <= 5; $n++) { //знаю, что должно быть около 6 массивов for ($a = 0; $a <= count($arr); $a++) { if(@array_sum($arr[$a]) > 0) { $array_symbols[$n][] = $arr[$a]; }else{ break; } } } 

    1 answer 1

     $index = 0; $array_symbols = []; // массив результатов foreach ($arr as $item) { if(array_sum($item) > 0) { $array_symbols[$index][] = $item; } elseif ($array_symbols) { // отбрасываем первые пустые результаты $index++; } } 

    So?