I have an array $MyArray
which has some elements which are also array (lets call them subarrays). I want to know how many elements the subarray with the most elements has. The problem is, that I don't know if the index exists:
max(
@count($MyArray[$i*7]),
@count($MyArray[$i*7+1]),
@count($MyArray[$i*7+2]),
@count($MyArray[$i*7+3]),
@count($MyArray[$i*7+4]),
@count($MyArray[$i*7+5]),
@count($MyArray[$i*7+6])
);
Struckture of $MyArray
:
Array(
12 => array (
0 => array ( 0 => 0, 1 => 1, ),
1 => array ( 0 => 13, 1 => 1, ),
2 => array ( 0 => 15, 1 => 1, ),
3 => array ( 0 => 20, 1 => 1, ),
4 => array ( 0 => 69, 1 => 1, )
),
5 => array (
0 => array ( 0 => 55, 1 => 1, ),
1 => array ( 0 => 32, 1 => 1, ),
2 => array ( 0 => 12, 1 => 1, ),
3 => array ( 0 => 21, 1 => 5, )
),
....
)
Can this be done better (faster)?
edit: I know foreach
and I don't want to loop over every element in this array. I just want an interval of it. @
is used, because I don't know if $MyArray[$i*7 + x]
is Null
or an array
.
$i
is a element of [0, 1, 2, 3, 4] (sometimes also 5)