• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP RecursiveArrayIterator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了RecursiveArrayIterator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: strtoupper

?>
" method="POST">
		
<input type="text" name="any_name">
<input type="submit" name="submit">
</form>	
		
		
		
		
		
	<?php 
if (isset($_POST['submit'])) {
    $var = $_POST['any_name'];
    $var = strtoupper($var);
    $str = file_get_contents('file.json');
    $json = json_decode($str, true);
    $iterator = new RecursiveArrayIterator($json);
    while ($iterator->valid()) {
        foreach ($iterator as $key => $value) {
            if (0 === strpos($key, $var)) {
                echo $key . ' : ' . $value . "<br/>";
            }
        }
        $iterator->next();
    }
}
?>
        </form>
    </body>
</html>
开发者ID:adil8z,项目名称:lab100,代码行数:31,代码来源:index.php


示例14: recursiveArraySearch

 /**
  * performs a search in a nested array
  * @param array $haystack the array to be searched
  * @param string $needle the search string
  * @param string $index optional, only search this key name
  * @return mixed the key of the matching field, otherwise false
  *
  * performs a search in a nested array
  *
  * taken from http://www.php.net/manual/en/function.array-search.php#97645
  */
 public static function recursiveArraySearch($haystack, $needle, $index = null)
 {
     $aIt = new RecursiveArrayIterator($haystack);
     $it = new RecursiveIteratorIterator($aIt);
     while ($it->valid()) {
         if ((isset($index) and $it->key() == $index or !isset($index)) and $it->current() == $needle) {
             return $aIt->key();
         }
         $it->next();
     }
     return false;
 }
开发者ID:kenwi,项目名称:core,代码行数:23,代码来源:helper.php


示例15: _parseData

 /**
  * Parse the upload data out of $_FILES.
  *
  * @access protected
  * @return void
  */
 protected function _parseData()
 {
     $data = array();
     // Form uploading
     if ($_FILES) {
         // via CakePHP
         if (isset($_FILES['data'])) {
             foreach ($_FILES['data'] as $key => $file) {
                 $count = count($file);
                 // Add model index if it doesn't exist
                 $iterator = new RecursiveArrayIterator($file);
                 if ($iterator->hasChildren() === false) {
                     $file = array('Fake' => $file);
                 }
                 foreach ($file as $model => $fields) {
                     foreach ($fields as $field => $value) {
                         if ($count > 1) {
                             $data[$model . '.' . $field][$key] = $value;
                         } else {
                             $data[$field][$key] = $value;
                         }
                     }
                 }
             }
             // via normal form or AJAX iframe
         } else {
             $data = $_FILES;
         }
         // AJAX uploading
     } else {
         if (isset($_GET[$this->ajaxField])) {
             $name = $_GET[$this->ajaxField];
             $mime = self::mimeType($name);
             if ($mime) {
                 $input = fopen("php://input", "r");
                 $temp = tmpfile();
                 $data[$this->ajaxField] = array('name' => $name, 'type' => $mime, 'stream' => true, 'tmp_name' => $temp, 'error' => 0, 'size' => stream_copy_to_stream($input, $temp));
                 fclose($input);
             }
         }
     }
     $this->_data = $data;
 }
开发者ID:xstation1021,项目名称:kdkitchen,代码行数:49,代码来源:Uploader.php


示例16: parseJson

 private function parseJson(\RecursiveArrayIterator $json, array $data, $level)
 {
     foreach ($json as $k => $j) {
         if (!isset($this->path[$level])) {
             return $data;
         }
         if ($k !== $this->path[$level] && $this->path[$level] !== '*') {
             continue;
         }
         if ($k === end($this->path)) {
             if (is_array($j)) {
                 $data = array_merge($data, $j);
             } else {
                 $data[] = $j;
             }
         }
         if ($json->hasChildren()) {
             $data = $this->parseJson($json->getChildren(), $data, $level + 1);
         }
     }
     return $data;
 }
开发者ID:ywarnier,项目名称:php-etl,代码行数:22,代码来源:JsonExtractor.php


示例17: __construct

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


示例18: __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


示例19: valid

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


示例20: current

 /** @return key() since that is the name we need
  */
 function current()
 {
     $result = parent::key();
     $parent = get_parent_class($result);
     if ($parent) {
         $interfaces = array_diff(class_implements($result), class_implements($parent));
         if ($interfaces) {
             $implements = array();
             foreach ($interfaces as $interface) {
                 $implements = array_merge($implements, class_implements($interface));
             }
             $interfaces = array_diff($interfaces, $implements);
             natcasesort($interfaces);
             $result .= ' (' . join(', ', $interfaces) . ')';
         }
     }
     return $result;
 }
开发者ID:cefalo19,项目名称:php-src,代码行数:20,代码来源:class_tree.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP RecursiveDirectoryIterator类代码示例发布时间:2022-05-23
下一篇:
PHP Rectangle类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap