$files = scandir("./doc");
$i = 2;
while($files[$i] != null ):
$files_end = $i;
$i++;
endwhile;

と、docフォルダに入っているファイル数をしらべるスクリプトですが、
while($files[$i] != null ):
の行で
Notice: Undefined offset: 5
と、Noticeが出て来ます。
この、Noticeを消すにはどうしたらいいでしょうか?