Similar to a comment, array_keys can be used to search for all keys containing the value you search for (zero in your case).
You then can loop over these positions and slice the array (see array_slice) into the parts.
Example (Demo):
$keys = array_keys($array, 0);
$parts = [];
$last = 0;
foreach ($keys as $key)
{
$last !== $key
&& $parts[] = array_slice($array, $last, $key - $last, true);
$last = $key;
}
$parts[] = isset($key) ? array_slice($array, $key, null, true) : $array;
This variant even preserves original keys, exemplary $parts output:
array(2) {
[0] => array(4) {
[0] => int(0)
[1] => int(1)
[2] => int(2)
[3] => int(3)
}
[1] => array(3) {
[4] => int(0)
[5] => int(4)
[6] => int(5)
}
}
Another alternative could be similar to some other answers outlined. The following variant does preserve keys, too:
$array = [0, 1 ,2 ,3, 0, 4, 5];
$parts = [];
$index = 0;
foreach ($array as $key => $number)
{
$number == 0 and $key and $index++;
$parts[$index][$key] = $number;
}
Output (Demo):
Array
(
[0] => Array
(
[0] => 0
[1] => 1
[2] => 2
[3] => 3
)
[1] => Array
(
[4] => 0
[5] => 4
[6] => 5
)
)