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


PHP RecursiveArrayIterator类代码示例

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


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

示例1: recursiveScan

 private function recursiveScan(\RecursiveArrayIterator $iterator)
 {
     while ($iterator->valid()) {
         $this->checkIblockData($iterator);
         if ($iterator->hasChildren()) {
             $this->recursiveScan($iterator->getChildren());
         } else {
             $this->checkIblockData($iterator);
         }
         $iterator->next();
     }
 }
开发者ID:maximaster,项目名称:tools.orm,代码行数:12,代码来源:Query.php

示例2: 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

示例3: find

 /**
  * Find a named route in a given array of routes.
  *
  * @param  string  $name
  * @param  array   $routes
  * @return array
  */
 public static function find($name, $routes)
 {
     if (array_key_exists($name, static::$names)) {
         return static::$names[$name];
     }
     $arrayIterator = new \RecursiveArrayIterator($routes);
     $recursiveIterator = new \RecursiveIteratorIterator($arrayIterator);
     // Since routes can be nested deep within sub-directories, we need to recursively
     // iterate through each directory and gather all of the routes.
     foreach ($recursiveIterator as $iterator) {
         $route = $recursiveIterator->getSubIterator();
         if (isset($route['name']) and $route['name'] == $name) {
             return static::$names[$name] = array($arrayIterator->key() => iterator_to_array($route));
         }
     }
 }
开发者ID:hpaul,项目名称:Google-short,代码行数:23,代码来源:finder.php

示例4: traverse

function traverse(RecursiveArrayIterator $iterator)
{
    while ($iterator->valid()) {
        if ($iterator->hasChildren()) {
            printf("HasChild: %s\n", $iterator->key());
            traverse($iterator->getChildren());
        } else {
            printf("%s => %s\n", $iterator->key(), $iterator->current());
        }
        $iterator->next();
    }
}
开发者ID:Eldahar,项目名称:PHP_Library,代码行数:12,代码来源:RecursiveArrayIterator1.php

示例5: walkArray

 /**
  * Walks through array
  * @param $array
  * @param $callback callable function($path, $value)
  */
 public static function walkArray($array, $callback, $iterator = null, $prefix = '')
 {
     if (is_null($iterator)) {
         $iterator = new \RecursiveArrayIterator($array);
     }
     while ($iterator->valid()) {
         if ($iterator->hasChildren()) {
             self::walkArray(null, $callback, $iterator->getChildren(), $prefix . '.' . $iterator->key());
         } else {
             call_user_func($callback, ltrim($prefix . '.' . $iterator->key(), '.'), $iterator->current());
         }
         $iterator->next();
     }
 }
开发者ID:myurasov,项目名称:mym-utils,代码行数:19,代码来源:Arrays.php

示例6: 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

示例7: buildResources

 /**
  * @param \RecursiveArrayIterator $iterator
  * @return mixed
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 protected function buildResources(\RecursiveArrayIterator $iterator)
 {
     if (count($this->mapping) == 0) {
         throw new HttpException(Codes::HTTP_BAD_REQUEST, 'Unable to generate CMMI Data, no mapping is known');
     }
     $this->resource = new Resource(new Link($this->request->getUri(), 'self'));
     if ($iterator->hasChildren()) {
         while ($iterator->valid()) {
             $childItem = $iterator->current();
             $this->addResource(new \RecursiveArrayIterator($childItem));
             $iterator->next();
         }
     } else {
         $this->addResource($iterator);
     }
     return $this->resource;
 }
开发者ID:pitoukhmer,项目名称:protalk,代码行数:22,代码来源:CMMIDataHelper.php

示例8: searchRecursive

 /**
  * Find a value also in nested arrays/objects
  *
  * @param mixed $needle The value to search for
  *
  * @return string The key of that value
  *
  * @since 1.0.0
  */
 public function searchRecursive($needle)
 {
     $aIt = new RecursiveArrayIterator($this);
     $it = new RecursiveIteratorIterator($aIt);
     while ($it->valid()) {
         if ($it->current() == $needle) {
             return $aIt->key();
         }
         $it->next();
     }
     return false;
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:21,代码来源:data.php

示例9: str_split

    <div>
        <label for="y">Input int. for y axis</label>
        <input type="text" name="y">
    </div>
    <div>
        <label for="directions">Input string for directions</label>
        <input type="text" name="directions">
    </div>
    <input type="submit" name="submit" value="Go!">
</form>


<?php 
$move_data = str_split($directions);
//var_dump($move_data);
$recusive = new RecursiveArrayIterator($move_data);
$reverse = 0;
while ($recusive->valid()) {
    $direction = $recusive->current();
    if ($direction == '~') {
        $reverse++;
        $recusive->next();
    } else {
        if ($reverse % 2) {
            if ($direction == '>') {
                $_x++;
            } elseif ($direction == '<') {
                $_x--;
            } elseif ($direction == 'v') {
                $_y++;
            } elseif ($direction == '^') {
开发者ID:jokuf,项目名称:solutions,代码行数:31,代码来源:points-solution.php

示例10: fetchCategoriesWithProducts

 /**
  * @param RecursiveArrayIterator $iterator
  */
 public function fetchCategoriesWithProducts(RecursiveArrayIterator $iterator)
 {
     while ($iterator->valid()) {
         if ($iterator->hasChildren()) {
             $this->fetchCategoriesWithProducts($iterator->getChildren());
         } else {
             if ($iterator->key() == 'countProducts' && $iterator->current() != '0') {
                 $this->_categoryWithProducts[$iterator->offsetGet('id')] = array('name' => $iterator->offsetGet('name'), 'full_path' => $iterator->offsetGet('full_path'), 'countProduct' => $iterator->offsetGet('countProducts'));
             }
             /*$this->_categoryWithProducts[$iterator->offsetGet('id')] =
               $iterator->offsetGet('countProducts');*/
         }
         $iterator->next();
     }
 }
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:18,代码来源:CsvCatalogGeneratorController.php

示例11: findNode

 /**
  * Find and return the bottom node in the given tree
  * @param \RecursiveArrayIterator $iterator
  * @param array $tree
  * @return mixed Array with 0: iterator, 1: value (reference)
  */
 protected function findNode(\RecursiveArrayIterator $iterator, $tree = [])
 {
     $find_key = array_shift($tree);
     foreach ($iterator as $key => &$value) {
         if ($key !== $find_key) {
             continue;
         }
         # $tree isn't null yet, meaning we still have to travel down
         # nodes in order to get to the last one... inception
         if (isset($tree[0])) {
             return $this->findNode($iterator->getChildren(), $tree);
         }
         # Return a reference to this current node - it's needed later. More details
         # are in the findValue() function. Yeah, it's kinda hackey
         return [$iterator, &$value];
     }
     return null;
 }
开发者ID:nabeelio,项目名称:codon-superobject,代码行数:24,代码来源:SuperObject.php

示例12: array_get

 function array_get($array, $searched, $index)
 {
     $aIt = new RecursiveArrayIterator($array);
     $it = new RecursiveIteratorIterator($aIt);
     while ($it->valid()) {
         if ((isset($index) and $it->key() == $index or !isset($index)) and $it->current() == $searched) {
             $c = $aIt->current();
             return $c;
             //				return $c[$key];
         }
         $it->next();
     }
     return FALSE;
 }
开发者ID:BGCX261,项目名称:zillatek-project-svn-to-git,代码行数:14,代码来源:MY_array_helper.php

示例13: __construct

 /**
  * @param array $array
  */
 public function __construct($array)
 {
     if (is_object($array)) {
         $array = $array->toArray();
     }
     parent::__construct($array);
 }
开发者ID:karousn,项目名称:SonataBlockBundle,代码行数:10,代码来源:RecursiveBlockIterator.php

示例14: __construct

 public function __construct(\ResourceBundle $bundle)
 {
     $storage = array();
     foreach ($bundle as $key => $value) {
         $storage[$key] = $value instanceof \ResourceBundle ? new self($value) : $value;
     }
     parent::__construct($storage);
 }
开发者ID:stealth35,项目名称:stdlib,代码行数:8,代码来源:ResourceBundleIterator.php

示例15: valid

 function valid()
 {
     if (!parent::valid()) {
         echo __METHOD__ . " = false\n";
         return false;
     } else {
         return true;
     }
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:9,代码来源:iterator_022.php


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