当前位置: 首页>>代码示例>>PHP>>正文


PHP RecursiveIteratorIterator::current方法代码示例

本文整理汇总了PHP中RecursiveIteratorIterator::current方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::current方法的具体用法?PHP RecursiveIteratorIterator::current怎么用?PHP RecursiveIteratorIterator::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RecursiveIteratorIterator的用法示例。


在下文中一共展示了RecursiveIteratorIterator::current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array_flatten

function array_flatten(array $array, $key_separator = '/')
{
    $result = array();
    // a stack of strings
    $keys = array();
    $prev_depth = -1;
    $iter = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::SELF_FIRST);
    // rewind() is necessary
    for ($iter->rewind(); $iter->valid(); $iter->next()) {
        $curr_depth = $iter->getDepth();
        $diff_depth = $prev_depth - $curr_depth + 1;
        //##### TODO: It would be nice to do this with a single function.
        while ($diff_depth > 0) {
            array_pop($keys);
            --$diff_depth;
        }
        /*
        Note:
        http://bugs.php.net/bug.php?id=52425
        array_shift/array_pop: add parameter that tells how many to elements to pop
        */
        array_push($keys, $iter->key());
        if (is_scalar($iter->current())) {
            $result[implode($key_separator, $keys)] = $iter->current();
        }
        $prev_depth = $curr_depth;
    }
    return $result;
}
开发者ID:grevutiu-gabriel,项目名称:iqatest,代码行数:29,代码来源:array_flatten.php

示例2: copyDir

 /**
  * @throws  \Seitenbau\FileSystem\FileSystemException
  */
 public static function copyDir($source, $destination)
 {
     if (!is_dir($source)) {
         throw new FileSystemException('Sourcedir "' . $source . '" does not exists');
     }
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
     if (!self::createDirIfNotExists($destination)) {
         return false;
     }
     // Verzeichnis rekursiv durchlaufen
     while ($iterator->valid()) {
         if (!$iterator->isDot()) {
             if ($iterator->current()->isDir()) {
                 // relativen Teil des Pfad auslesen
                 $relDir = str_replace($source, '', $iterator->key());
                 // Ziel-Verzeichnis erstellen
                 if (!self::createDirIfNotExists($destination . $relDir)) {
                     return false;
                 }
             } elseif ($iterator->current()->isFile()) {
                 $destinationFile = $destination . str_replace($source, '', $iterator->key());
                 if (!copy($iterator->key(), $destinationFile)) {
                     return false;
                 }
             }
         }
         $iterator->next();
     }
     return true;
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:33,代码来源:FileSystem.php

示例3: rmdir

	public function rmdir($path) {
		if (!$this->isDeletable($path)) {
			return false;
		}
		try {
			$it = new \RecursiveIteratorIterator(
				new \RecursiveDirectoryIterator($this->getSourcePath($path)),
				\RecursiveIteratorIterator::CHILD_FIRST
			);
			/**
			 * RecursiveDirectoryIterator on an NFS path isn't iterable with foreach
			 * This bug is fixed in PHP 5.5.9 or before
			 * See #8376
			 */
			$it->rewind();
			while ($it->valid()) {
				/**
				 * @var \SplFileInfo $file
				 */
				$file = $it->current();
				if (in_array($file->getBasename(), array('.', '..'))) {
					$it->next();
					continue;
				} elseif ($file->isDir()) {
					rmdir($file->getPathname());
				} elseif ($file->isFile() || $file->isLink()) {
					unlink($file->getPathname());
				}
				$it->next();
			}
			return rmdir($this->getSourcePath($path));
		} catch (\UnexpectedValueException $e) {
			return false;
		}
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:35,代码来源:local.php

示例4: findDirectories

 public static function findDirectories($rootDir, $multiMap = true)
 {
     if (!is_dir($rootDir)) {
         throw new \LogicException($rootDir . ' is not a directory');
     }
     $elements = array();
     $d = @dir($rootDir);
     if (!$d) {
         throw new \LogicException('Directory is not readable');
     }
     $dirs = array();
     $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($rootDir, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
     while ($it->valid()) {
         if (!$it->isDir()) {
             $it->next();
         } else {
             $cur = $it->current();
             if ($cur->isDir()) {
                 if ($multiMap) {
                     $dirs[$cur->getPath()][] = $cur->getFilename();
                 } else {
                     $dirs[] = $cur->getPath();
                 }
             }
             $it->next();
         }
     }
     return $dirs;
 }
开发者ID:shenlu2011,项目名称:Hub-master,代码行数:29,代码来源:Util.php

示例5: get_directory_list

function get_directory_list($settings = false)
{
    $directory = !empty($settings['dir']) ? $settings['dir'] : CLIENT_DIR . "/";
    $array = array();
    $array['dirs'] = array();
    $array['host'] = array();
    $array['root'] = array();
    if (!is_dir($directory)) {
        return false;
    }
    $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::CHILD_FIRST);
    // Loop through directories
    while ($dir->valid()) {
        try {
            $file = $dir->current();
            ob_start();
            echo $file;
            $data = ob_get_contents();
            ob_end_clean();
            $data = trim($data);
            if (basename($data) != '.' && basename($data) != '..') {
                $array['host'][] = $data;
                $array['root'][] = str_replace(ROOT_DIR, "", $data);
                if (is_dir($data) && !in_array($data . "/", $array['dirs'])) {
                    $array['dirs'][] = $data . "/";
                }
            }
            unset($data);
            $dir->next();
        } catch (UnexpectedValueException $e) {
            continue;
        }
    }
    return isset($array) ? $array : false;
}
开发者ID:rasclatt,项目名称:ZipEngine,代码行数:35,代码来源:function.get_directory_list.php

示例6: current

 function current()
 {
     if ($this->rit_flags & self::BYPASS_CURRENT) {
         return parent::current();
     } else {
         return $this->getPrefix() . $this->getEntry() . $this->getPostfix();
     }
 }
开发者ID:ookwudili,项目名称:chisimba,代码行数:8,代码来源:stdlib_class_inc.php

示例7: testIterate

 public function testIterate()
 {
     $sitemap = new Sitemap("h-1", "home", null);
     $n1 = $sitemap->getRoot()->addChild(new Node("h-1-1", "n1", null));
     $n2 = $n1->addChild(new Node("h-1-1-1", "n2", null));
     $n3 = $n1->addChild(new Node("h-1-1-2", "n3", null));
     $it = new \RecursiveIteratorIterator($sitemap->getIterator(), \RecursiveIteratorIterator::SELF_FIRST);
     $it->rewind();
     $this->assertEquals($sitemap->getRoot(), $it->current(), "Se esperaba que el primer elemento del iterador sea la raiz.");
     $it->next();
     $this->assertEquals($n1, $it->current(), "Se esperaba que el segundo elemento del iterador sea el primer hijo de la raiz.");
     $it->next();
     $this->assertEquals($n2, $it->current(), "Se esperaba que el tercer elemento del iterador sea el primer hijo del primer hijo de la raiz.");
     $it->next();
     $this->assertEquals($n3, $it->current(), "Se esperaba que el cuarto elemento del iterador sea el segundo hijo del primer hijo de la raiz.");
     $it->next();
     $this->assertFalse($it->valid(), "Se esperaba que el luego del cuarto elemento el iterador quede inválido.");
 }
开发者ID:bluegrass,项目名称:blues,代码行数:18,代码来源:SitemapIteratorTest.php

示例8: current

 function current()
 {
     $current = parent::current();
     $key = parent::key();
     $retValue = "<td style='width:150px;border:1px solid black;'>\n\t\t\t        \t\t   \t<input ";
     if ($key == 'Id') {
         $retValue .= "readonly ";
     }
     $retValue .= "type='text' name='" . htmlspecialchars($key) . "' value='" . htmlspecialchars($current) . "'>\n\t\t\t        \t\t</td>";
     return $retValue;
 }
开发者ID:billyboy429,项目名称:EmployeeForm,代码行数:11,代码来源:employee.php

示例9: current

 /**
  * Get the current element
  *
  * @see       http://www.php.net/RecursiveIteratorIterator
  * @return mixed
  */
 public function current()
 {
     $current = parent::current();
     if (is_array($current)) {
         $this->namespaceStack[] = $this->key();
         $this->nodeType = self::NODE_PARENT;
     } else {
         $this->nodeType = self::NODE_ITEM;
     }
     return $current;
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:17,代码来源:PropelConfigurationIterator.php

示例10: search

 /**
  * Searches value inside a multidimensional array, returning its index
  *
  * Original function by "giulio provasi" (link below)
  *
  * @param mixed|array $haystack
  *   The haystack to search
  *
  * @param mixed $needle
  *   The needle we are looking for
  *
  * @param mixed|optional $index
  *   Allow to define a specific index where the data will be searched
  *
  * @return integer|string
  *   If given needle can be found in given haystack, its index will
  *   be returned. Otherwise, -1 will
  *
  * @see http://www.php.net/manual/en/function.array-search.php#97645
  */
 public static function search($haystack, $needle, $index = NULL)
 {
     if (is_null($haystack)) {
         return -1;
     }
     $arrayIterator = new \RecursiveArrayIterator($haystack);
     $iterator = new \RecursiveIteratorIterator($arrayIterator);
     while ($iterator->valid()) {
         if ((isset($index) and $iterator->key() == $index or !isset($index)) and $iterator->current() == $needle) {
             return $arrayIterator->key();
         }
         $iterator->next();
     }
     return -1;
 }
开发者ID:nextframework,项目名称:next,代码行数:35,代码来源:ArrayUtils.php

示例11: valid

 public function valid()
 {
     $valid = $this->iterator->valid();
     while ($valid) {
         $filename = $this->iterator->current()->getPathname();
         $ext = Fn::fileExtension($filename);
         if ($ext !== 'original-filename' && is_file($filename . '.original-filename')) {
             $this->currentFilename = $filename;
             break;
         }
         $this->iterator->next();
         $valid = $this->iterator->valid();
     }
     return $valid;
 }
开发者ID:arnapou,项目名称:gw2tools,代码行数:15,代码来源:FileVault.php

示例12: search

 /**
  * Finder method to be able to find resources by context name
  * and attributes.  Example usage:
  * 
  * <code>
  * 
  * </code>
  *
  * @param Zend_Tool_Project_Profile_Resource_SearchConstraints|string|array $searchParameters
  * @return Zend_Tool_Project_Profile_Resource
  */
 public function search($searchConstraints)
 {
     if (!$searchConstraints instanceof Zend_Tool_Project_Profile_Resource_SearchConstraints) {
         $searchConstraints = new Zend_Tool_Project_Profile_Resource_SearchConstraints($searchConstraints);
     }
     $this->rewind();
     $riIterator = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
     $foundResource = false;
     $currentConstraint = $searchConstraints->getConstraint();
     $foundDepth = 0;
     while ($currentResource = $riIterator->current()) {
         // if current depth is less than found depth, end
         if ($riIterator->getDepth() < $foundDepth) {
             break;
         }
         if (strtolower($currentResource->getName()) == strtolower($currentConstraint->name)) {
             $paramsMatch = true;
             // @todo check to ensure params match (perhaps)
             if (count($currentConstraint->params) > 0) {
                 $currentResourceAttributes = $currentResource->getAttributes();
                 foreach ($currentConstraint->params as $paramName => $paramValue) {
                     if (!isset($currentResourceAttributes[$paramName]) || $currentResourceAttributes[$paramName] != $paramValue) {
                         $paramsMatch = false;
                         break;
                     }
                 }
             }
             if ($paramsMatch) {
                 $foundDepth = $riIterator->getDepth();
                 if (($currentConstraint = $searchConstraints->getConstraint()) == null) {
                     $foundResource = $currentResource;
                     break;
                 }
             }
         }
         $riIterator->next();
     }
     return $foundResource;
 }
开发者ID:H38uS,项目名称:Impulsion,代码行数:50,代码来源:Container.php

示例13: UnlinkDPL

function UnlinkDPL()
{
    global $TopDirectory;
    try {
        $TopDirectoryCnt = count($TopDirectory);
        //print "TopDirectoryCnt: " . $TopDirectoryCnt . $NL;
        foreach ($TopDirectory as $Dir => $RM) {
            $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Dir));
            while ($it->valid()) {
                if ($it->isFile()) {
                    $ext = pathinfo($it->current(), PATHINFO_EXTENSION);
                    if ($ext == "dpl") {
                        unlink($it->getPathName());
                    }
                }
                $it->next();
            }
        }
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
开发者ID:HenrikTolboel,项目名称:LinnDS-jukebox,代码行数:22,代码来源:FileUtils.php

示例14: rarray_search

/**
 * 
 * Search for needle in a recursive array
 * @author http://www.php.net/manual/en/function.array-search.php#97645
 * 
 * @param $haystack
 * @param $needle
 * @param $index
 */
function rarray_search($needle, $haystack, $index = null)
{
	$aIt	= new RecursiveArrayIterator($haystack);
	$it		= new RecursiveIteratorIterator($aIt);
	
	// Tar bort ".www" om det finns för bättre jämföring
	$needle = preg_replace('/\bwww./', '', $needle);
   
	while($it->valid())
    {
    	// Tar bort ".www" om det finns för bättre jämföring
    	$current = preg_replace('/\bwww./', '', $it->current());

		if (((isset($index) AND ($it->key() == $index)) OR (!isset($index))) AND ($current == $needle))
		{
			return $aIt->key();
		}
		$it->next();
	}

	return FALSE;
}
开发者ID:nicholasruunu,项目名称:Arbetsprov,代码行数:31,代码来源:MY_array_helper.php

示例15: parseContents

 protected function parseContents(\SimpleXMLIterator $iterator, FileCollection $files)
 {
     // Load files
     $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
     $iterator->rewind();
     $lastDepth = -1;
     $path = array();
     while ($iterator->valid()) {
         if ($lastDepth > $iterator->getDepth()) {
             array_pop($path);
             while ($lastDepth != $iterator->getDepth()) {
                 array_pop($path);
                 $lastDepth--;
             }
         } elseif ($lastDepth === $iterator->getDepth()) {
             array_pop($path);
         }
         $elt = $iterator->current();
         if ($elt->getName() === 'file') {
             $path[] = (string) $elt['name'];
             $filePath = implode('/', $path);
             $file = new File($filePath, $filePath, $elt['role']);
             // Find file tasks
             $tasks = $elt->children('http://pear.php.net/dtd/tasks-1.0');
             foreach ($tasks as $task) {
                 $options = current((array) $task->attributes());
                 $file->addTask($task->getName(), $options);
             }
             $files[] = $file;
         } elseif ($elt->getName() === 'dir') {
             $path[] = ((string) $elt['name'] === '/' ? '' : $elt['name']) . (isset($elt['baseinstalldir']) && (string) $elt['baseinstalldir'] !== '/' ? '/' . $elt['baseinstalldir'] : '');
         }
         $lastDepth = $iterator->getDepth();
         $iterator->next();
     }
 }
开发者ID:rosstuck,项目名称:Pok,代码行数:36,代码来源:Loader.php


注:本文中的RecursiveIteratorIterator::current方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。