I was looking for a way to name my files in numbers,eg 1.text,2.text...
But this should be done automatically. When saving A new file, the program should take the maximum number among the files in the directory, and name the new folder that number plus one.
A hint given is that we can use auto increment. How can we do so?
$fileDir = 'your_file_dir';
$fileIterator = new FilesystemIterator($fileDir, FilesystemIterator::SKIP_DOTS);
$numberOfFiles = iterator_count($fileIterator)+1; // Count the number of files in $fileDir
$f = fopen("{$fileDir}/{$numberOfFiles}.txt", 'w');
fclose($f);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.