The reason the loop stops is that the count() of the array $pizza2 changes each time the loop runs. So the conditions of your for statement are changing on each loop, and when it reaches 3, your array is now shorter, so the condition is met and the loop stops. By the time $i has reached three, the array has been shortened to only three elements. This will demonstrate what's happening:
$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
$pizza2 = explode(" ",$pizza);
for($i = 0; $i<count($pizza2); $i++)
{
echo "Array #".$i." is: <b>".$pizza2[$i]. "</b> ";
unset($pizza2[$i]);
echo "pizza2 has ".count($pizza2)." elements";
}
To solve this, you could get the initial length of the array and store it:
$length = count($pizza2);
for($i = 0; $i<$length; $i++)
{//etc... as before
You could also simplify by using a foreach():
foreach ($pizza2 as $key => $value){
echo "Array #" . $key . " is: " . $value ."<br/>";
}