All this does is iterates through the array, starting with the first element [0], and adding 1 to it for each loop. When the last call to array_shift() returns false (because it cant shift any further) you will break out of the while loop.
Im not 100% sure what your question actualy is, but there are other ways of doing this. Just as an example...
$num = 0;
while ($num <= count($array)) {
echo $num;
$num++
}