PHP未定义的数组循环偏移量

I have simple codes down below :

   $i = 0;    
    $array = array('name','email','address');

    while ($array[$i]) {
    echo "$array[$i]<br>";

    $i++;
    }

My problem : After echoing name, email, address without problem, It generates an error message "Undefined offset: 3". What is I insist to use WHILE loop instead of IF condition. How to deal with the error. Thank you

<?php
$array = array('name','email','address');
for ($i=0; $i<sizeof($array);$i++) {
    echo "$array[$i]<br>";
}
?>