Hi, I have a script here downloaded from the net. It works fine, I'm just not quite clear how it works.
Code:
function save_file($filename, $contents) {
    $i = 0;
    do {
        $handle = fopen($filename, "w+");
        $fout = fwrite($handle, $contents);
        fclose($handle);
        $i++;
    } while(filesize($filename) < 5 && $i < 5);
}
Can someone please explain the while() part? Why does it need a loop to save files? and what is the $i for?

any information would be greatly appreciated.