本文整理汇总了PHP中DirectoryIterator::rewind方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryIterator::rewind方法的具体用法?PHP DirectoryIterator::rewind怎么用?PHP DirectoryIterator::rewind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryIterator
的用法示例。
在下文中一共展示了DirectoryIterator::rewind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rewind
/**
*/
public function rewind()
{
parent::rewind();
while ($this->isDot()) {
$this->next();
}
}
示例2: rewind
/**
* Rewinds the cache entry iterator to the first element
*
* @return void
* @api
*/
public function rewind()
{
if ($this->cacheFilesIterator === null) {
$this->cacheFilesIterator = new \DirectoryIterator($this->cacheDirectory);
}
$this->cacheFilesIterator->rewind();
while (substr($this->cacheFilesIterator->getFilename(), 0, 1) === '.' && $this->cacheFilesIterator->valid()) {
$this->cacheFilesIterator->next();
}
}
示例3: getAvailableLanguages
/**
* Returns the available languages for this documentation format
*
* @return array Array of string language codes
* @api
*/
public function getAvailableLanguages()
{
$languages = array();
$languagesDirectoryIterator = new \DirectoryIterator($this->formatPath);
$languagesDirectoryIterator->rewind();
while ($languagesDirectoryIterator->valid()) {
$filename = $languagesDirectoryIterator->getFilename();
if ($filename[0] != '.' && $languagesDirectoryIterator->isDir()) {
$language = $filename;
$languages[] = $language;
}
$languagesDirectoryIterator->next();
}
return $languages;
}
示例4: getDocumentationFormats
/**
* Returns the available documentation formats for this documentation
*
* @return array Array of \TYPO3\Flow\Package\DocumentationFormat
* @api
*/
public function getDocumentationFormats()
{
$documentationFormats = array();
$documentationFormatsDirectoryIterator = new \DirectoryIterator($this->documentationPath);
$documentationFormatsDirectoryIterator->rewind();
while ($documentationFormatsDirectoryIterator->valid()) {
$filename = $documentationFormatsDirectoryIterator->getFilename();
if ($filename[0] != '.' && $documentationFormatsDirectoryIterator->isDir()) {
$documentationFormat = new \TYPO3\Flow\Package\Documentation\Format($filename, $this->documentationPath . $filename . '/');
$documentationFormats[$filename] = $documentationFormat;
}
$documentationFormatsDirectoryIterator->next();
}
return $documentationFormats;
}
示例5: delete
public static function delete($dir)
{
$dir = new DirectoryIterator($dir);
foreach ($dir as $file) {
if ($file->isDot()) {
continue;
} else {
if ($file->isDir()) {
self::delete($file->getRealPath());
} else {
if ($file->isFile()) {
unlink($file->getRealPath());
}
}
}
}
$dir->rewind();
rmdir($dir->getRealPath());
}
示例6: scanRecursiveDir
/**
* scan folders recursive and returns all folders
* @param string $directory
* @param string exclude
* @return array|string
*/
public function scanRecursiveDir($directory, $exclude = '')
{
try {
$file = '';
$it = new DirectoryIterator($directory);
for ($it->rewind(); $it->valid(); $it->next()) {
if ($it->isDir() && !$it->isDot()) {
if ($it->getFilename() == $exclude) {
continue;
}
$file[] = $it->getFilename();
}
}
return $file;
} catch (Exception $e) {
$logger = new debug_logger(MP_LOG_DIR);
$logger->log('error', 'php', 'An error has occured : ' . $e->getMessage(), debug_logger::LOG_VOID);
}
}
示例7: getPackageDocumentations
/**
* Returns the available documentations for this package
*
* @return array Array of \TYPO3\Flow\Package\Documentation
* @api
*/
public function getPackageDocumentations()
{
$documentations = array();
$documentationPath = $this->getDocumentationPath();
if (is_dir($documentationPath)) {
$documentationsDirectoryIterator = new \DirectoryIterator($documentationPath);
$documentationsDirectoryIterator->rewind();
while ($documentationsDirectoryIterator->valid()) {
$filename = $documentationsDirectoryIterator->getFilename();
if ($filename[0] != '.' && $documentationsDirectoryIterator->isDir()) {
$filename = $documentationsDirectoryIterator->getFilename();
$documentation = new Documentation($this, $filename, $documentationPath . $filename . '/');
$documentations[$filename] = $documentation;
}
$documentationsDirectoryIterator->next();
}
}
return $documentations;
}
示例8: rewind
function rewind()
{
echo __METHOD__ . "\n";
parent::rewind();
}
示例9: rewind
public function rewind()
{
parent::rewind();
}
示例10: rewind
/**
* ( excerpt from http://php.net/manual/en/filesystemiterator.rewind.php )
*
* Rewinds the directory back to the start.
*
* @return mixed No value is returned.
*/
public function rewind()
{
parent::rewind();
$this->goPastDotsIfNeeded();
}
示例11:
echo '<tr><td>isWritable()</td><td> '; var_dump($item->isWritable()); echo '</td></tr>';
echo '<tr><td>isReadable()</td><td> '; var_dump($item->isReadable()); echo '</td></tr>';
echo '<tr><td>isExecutable(</td><td> '; var_dump($item->isExecutable()); echo '</td></tr>';
echo '<tr><td>isFile()</td><td> '; var_dump($item->isFile()); echo '</td></tr>';
echo '<tr><td>isDir()</td><td> '; var_dump($item->isDir()); echo '</td></tr>';
echo '<tr><td>isLink()</td><td> '; var_dump($item->isLink()); echo '</td></tr>';
echo '<tr><td>getFileInfo()</td><td> '; var_dump($item->getFileInfo()); echo '</td></tr>';
echo '<tr><td>getPathInfo()</td><td> '; var_dump($item->getPathInfo()); echo '</td></tr>';
echo '<tr><td>openFile()</td><td> '; var_dump($item->openFile()); echo '</td></tr>';
echo '<tr><td>setFileClass()</td><td> '; var_dump($item->setFileClass()); echo '</td></tr>';
echo '<tr><td>setInfoClass()</td><td> '; var_dump($item->setInfoClass()); echo '</td></tr>';*/
}
}
echo '</table>';
// while 循环
$directoryIt->rewind();
while ($directoryIt->valid()) {
// 过滤 . 和 ..
if (!$directoryIt->isDot()) {
echo $directoryIt->key(), '=>', $directoryIt->current(), '<br />';
}
$directoryIt->next();
}
// 获得该目录的所有文件和下级文件夹的文件
/*$rdIt = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('/data/www/yii2/learn/backend'));
foreach ($rdIt AS $name => $object) {
echo $object.'<br/>';
}*/
echo '----------------------------------- DirectoryIterator END ---------------------------------', '<br />';
echo '--------------------------------- SimpleXMLIterator START-----------------------------------', '<br />';
/**
示例12: seek
$di->seek(2);
$n = 0;
while ($di->valid()) {
$n++;
$di->next();
}
echo "With seek(2) we get {$n}\n";
$di->seek(0);
$m = 0;
while ($di->valid()) {
$m++;
$di->next();
}
echo "With seek(0) we get {$m}\n";
$o = 0;
$di->rewind();
while ($di->valid()) {
$o++;
$di->next();
}
echo "Without seek we get {$o}\n";
$p = 0;
$di->seek($o + 1);
while ($di->valid()) {
$p++;
$di->next();
}
var_dump($n !== $m, $m === $o, $p === 0);
?>
===DONE===
示例13: rewind
/**
* Rewind the Iterator to the first resource.
*/
public function rewind()
{
$this->iterator->rewind();
}
示例14: getDocumentationFormats
/**
* Returns the available documentation formats for this documentation
*
* @return array Array of \F3\FLOW3\Package\DocumentationFormat
* @author Christopher Hlubek <hlubek@networkteam.com>
* @api
*/
public function getDocumentationFormats()
{
$documentationFormats = array();
$documentationFormatsDirectoryIterator = new \DirectoryIterator($this->documentationPath);
$documentationFormatsDirectoryIterator->rewind();
while ($documentationFormatsDirectoryIterator->valid()) {
$filename = $documentationFormatsDirectoryIterator->getFilename();
if ($filename[0] != '.' && $documentationFormatsDirectoryIterator->isDir()) {
$documentationFormat = $this->objectFactory->create('F3\\FLOW3\\Package\\Documentation\\Format', $filename, $this->documentationPath . $filename . '/');
$documentationFormats[$filename] = $documentationFormat;
}
$documentationFormatsDirectoryIterator->next();
}
return $documentationFormats;
}
示例15: substr
$request = substr($_SERVER['REDIRECT_URL'],strlen($_SERVER['PHP_SELF'])-9);
define('NUM_PER_PAGE',3);
//need to sanatize
preg_match("#page/([0-9]+)#",$request,$matches);
$page = (int)$matches[1];
preg_match("#photo/([0-9A-Za-z-]+)#",$request,$matches);
$requestedPhoto = $matches[1];
$photos = new DirectoryIterator('./photos');
$fileNames = $currentPageFiles = array();
$photos->rewind();
foreach($photos as $photo) {
if(!$photo->isDot() && $photo->isFile()) {
$numFiles++;
$fileNames[] = $photo->getFilename();
}
}
$numPages = ceil($numFiles/NUM_PER_PAGE);
if($requestedPhoto && in_array($requestedPhoto.'.jpg',$fileNames)) {
$exif = exif_read_data('./photos/'.$requestedPhoto.'.jpg');
$currentPhoto = $exif;
$currentPhoto['webHref'] = '/source/chapter7/browser/photos/'.$requestedPhoto.'.jpg';
$currentPage = ceil((array_search($requestedPhoto.'.jpg',$fileNames)+1)/NUM_PER_PAGE);
$currentPageFiles = array_slice($fileNames,NUM_PER_PAGE*($currentPage-1),NUM_PER_PAGE);