Php 我怎样才能找到字典中的所有文件?
我正在研究一种节省CPU的方法,在启动我的游戏服务器之前将所有资源加载到ram中,而不是动态加载到ram中 所以我把所有的数据包都保存在字典里。这些文件有随机名称。我怎样才能找到字典里的每个文件?我需要这样的东西:Php 我怎样才能找到字典中的所有文件?,php,Php,我正在研究一种节省CPU的方法,在启动我的游戏服务器之前将所有资源加载到ram中,而不是动态加载到ram中 所以我把所有的数据包都保存在字典里。这些文件有随机名称。我怎样才能找到字典里的每个文件?我需要这样的东西: $path = //path to dictionary foreach(//get dictionary files as $packet){ $filename = //getfile name if(!isset($this->chunkCache[$file
$path = //path to dictionary
foreach(//get dictionary files as $packet){
$filename = //getfile name
if(!isset($this->chunkCache[$filename])){
$this->chunkCache[$filename] = $packet;
}
}
这可能吗?请检查:
readdir()
这段代码应该列出某个目录中的所有条目:
$path = //path to dictionary
if ($handle = opendir($path)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "$entry\n";
}
}
closedir($handle);
}