There is a script that counts the number of files in a folder, and, based on the calculations, assigns a unique id (int) to the file name.
That is, if there are 39 files, then 40 is written into the variable, then a file is created there and the total number of files already becomes 40.
$number = $i; // сюда записывается результат подсчета файлов в папке $text='example'; $format='.php'; $fulltext.= $text . $number . $format; //получилось example40.php After the full operation, the text is added to the main file in the list of the form:
... example37.php example38.php example39.php example40.php And in case of deletion from the middle of the list, for example : example38.php and deleting its file
After the file counting procedure is repeated, the script counts again 39 files in the folder, then adds +1 to the counting and writes it to the main file, and we get a line like
...
example37.php example39.php example40.php example40.php Any idea how to solve the problem? Here is the counting script
// Counting the number of files in the content folder
$path = 'content'; $dir = opendir ("$path"); $i = 0; while (false !== ($file = readdir($dir))) { if (strpos($file, '.txt',1) ) { $i++; } } $i++; $number = $i;