Opat by som potreboval pomoct. Ako by som spravil to, aby sa nacitavali hodnoty na riadok 0,1,2,3....a nie ako teraz, ze to nacitava nove hodnoty dolu a stare su hore.
As someone has mentioned already, using fopen() in r+ mode overwrites the beginning of the file with new data. So, if you want to append new data to the beginning of the file, do so as follows:
<?php
$filename = "myfile.txt"; //first, obtain the data initially present in the text file
$ini_handle = fopen($filename, "r");
$ini_contents = fread($ini_handle, filesize($filename));
fclose($ini_handle); //done obtaining initially present data
//write new data to the file, along with the old data
$handle = fopen($filename, "w+");
$writestring = "text to write to file\n" . $ini_contents;
if (fwrite($handle, $writestring) === false) {
echo "Cannot write to text file. <br />";
}
fclose($handle);
?>