/*I use your exact proposed code with only some few additional lines. The idea is more or less the same of the one proposed by @elias, but in this solution there cannot be conflicts on the keys since each file in the directory has a different filename and so ad ding it to the key solves the conflicts. The first part of the key is the datetime string formatted in a manner such that I can lexicographically compare two of them.*/
// Open a directory, and read its contents echo "http://127.0.0.1/5F/func_directory_readdir2.php<br />"; if (is_dir($dir)){ if ($dh = opendir($dir)){ for ($i = -1; $i < 100; $i++) { while (($file = readdir($dh)) !== false){ echo "\$pdf->AjouterChapitre("; echo $i++;