prep('', 'SELECT chapter_hash FROM mangadex_chapters WHERE chapter_hash IN ('.$replace.')', $hashes, 'fetchAll', PDO::FETCH_COLUMN, -1); return \array_diff($hashes, $dbHashes); } $handle = opendir($dirPath); $dirChunk = []; while (false !== ($entry = readdir($handle))) { if ($entry{0} === '.') { continue; } $dirChunk[] = $entry; if (count($dirChunk) >= 100) { $orphanedHashes = checkChapterHashes($dirChunk); $dirChunk = []; foreach ($orphanedHashes AS $hash) { echo "$hash\n"; } } } if (count($dirChunk) > 0) { $orphanedHashes = checkChapterHashes($dirChunk); $dirChunk = []; foreach ($orphanedHashes AS $hash) { echo "$hash\n"; } }