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


PHP RecursiveArrayIterator::getChildren方法代码示例

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


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

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

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

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

示例4: getChildren

 function getChildren()
 {
     echo __METHOD__ . "\n";
     return parent::getChildren();
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:5,代码来源:iterator_021.php

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

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

示例7: getChildren

 public function getChildren()
 {
     echo "MyArrIter::getChildren\n";
     return parent::getChildren();
 }
开发者ID:jinguanio,项目名称:david,代码行数:5,代码来源:iterator_run.php

示例8: getChildren

 function getChildren()
 {
     echo __METHOD__ . "()\n";
     self::fail(2, __METHOD__);
     return parent::getChildren();
 }
开发者ID:badlamer,项目名称:hhvm,代码行数:6,代码来源:iterator_047.php

示例9: array

 function traverse_structure($ids)
 {
     $return_ids = array();
     $iterator = new RecursiveArrayIterator($ids);
     while ($iterator->valid()) {
         if ($iterator->hasChildren()) {
             $return_ids = array_merge($return_ids, $this->traverse_structure($iterator->getChildren()));
         } else {
             if ($iterator->key() == 'int') {
                 $return_ids = array_merge($return_ids, array($iterator->current()));
             }
         }
         $iterator->next();
     }
     return $return_ids;
 }
开发者ID:AndyRocioGtz,项目名称:Registros,代码行数:16,代码来源:openerp.class.php

示例10: walkInputArray

 /**
  * Walks through input array
  *
  * @param        $array
  * @param        $callback callable function($path, $value)
  * @param null   $iterator
  * @param string $prefix
  */
 private function walkInputArray($array, $callback, $iterator = null, $prefix = '')
 {
     if (!$iterator) {
         $iterator = new \RecursiveArrayIterator($array);
     }
     while ($iterator->valid()) {
         $key = $iterator->key();
         if ($iterator->hasChildren()) {
             $this->walkInputArray(null, $callback, $iterator->getChildren(), $prefix . '.' . $key);
         } else {
             call_user_func($callback, ltrim($prefix . '.' . $key, '.'), $iterator->current());
         }
         $iterator->next();
     }
 }
开发者ID:myurasov,项目名称:rest-api-tools,代码行数:23,代码来源:AbstractRESTController.php

示例11: highlightElement

 private function highlightElement($indexArray, $menuArray = null, $nr = 0)
 {
     //index to get
     $i = $indexArray[$nr];
     //if menu is null take menuArray
     if ($menuArray == null) {
         $menuArray = $this->menuArray;
     }
     //create itterator
     $iter = new RecursiveArrayIterator($menuArray);
     //move to current index
     $iter->seek($i);
     //move down until we have found the element - then set the css-class for that element
     if (is_array($iter->current())) {
         $this->highlightElement($indexArray, $iter->getChildren(), $nr + 1);
     } else {
         $iter->current()->cssClass = $this->cssClass;
     }
 }
开发者ID:bthurvi,项目名称:oophp,代码行数:19,代码来源:CDynamicDropDownMenu.php

示例12: reducer

 /**
  * Helper to `names`, which recursively traverses the iterator appending
  * new keys onto the base-so-far.
  *
  * @param \RecursiveArrayIterator $it
  * @param string $base
  * @param array $names
  */
 private function reducer(\RecursiveArrayIterator $it, $base, &$names)
 {
     while ($it->valid()) {
         $sub_base = sprintf('%s[%s]', $base, $it->key());
         if ($it->hasChildren()) {
             $this->reducer($it->getChildren(), $sub_base);
         } else {
             $names[] = $sub_base;
         }
         $it->next();
     }
 }
开发者ID:haldayne,项目名称:customs,代码行数:20,代码来源:UploadIterator.php

示例13: array

<?php

class Persona
{
    public $nome = 'Mario';
    public $cognome = 'Rossi';
    public $telefono = array('cellulare' => '114499', 'ufficio' => '224433');
    public $socials = array('twitter' => 'rossi', 'facebook' => 'http://www.facebook.com/rossi');
}
$iterator = new RecursiveArrayIterator(new Persona());
foreach ($iterator as $index => $value) {
    if ($iterator->hasChildren()) {
        foreach ($iterator->getChildren() as $key => $child) {
            echo $key . ': ' . $child, PHP_EOL;
        }
    } else {
        echo $index . ': ' . $value, PHP_EOL;
    }
}
开发者ID:GrUSP,项目名称:php_best_practices,代码行数:19,代码来源:recursive_array_iterator.php

示例14: encode_iterator

 protected static function encode_iterator(RecursiveArrayIterator $iterator, $options, $depth)
 {
     $json = array();
     while ($iterator->valid()) {
         $key = $iterator->key();
         $value = $iterator->current();
         if ($value instanceof JSExpression) {
             var_dump($value);
             $json[$key] = $value->json_encode($options);
         } else {
             if ($iterator->hasChildren()) {
                 if (!($depth > 0)) {
                     throw new Exception("Maximum depth reached");
                 }
                 $json[$key] = static::encode_iterator($iterator->getChildren(), $options, $depth - 1);
             } else {
                 $json[$key] = static::encode_value($iterator->current(), $options);
             }
         }
         $iterator->next();
     }
     var_dump($json);
     if (self::is_numeric_array($json)) {
         return '[' . implode(",", $json) . ']';
     } else {
         foreach (array_keys($json) as $key) {
             $json[$key] = static::encode_key($key, $options) . ':' . $json[$key];
         }
         return '{' . implode(",", $json) . '}';
     }
 }
开发者ID:colin-kiegel,项目名称:libSQLPrefetch,代码行数:31,代码来源:jsonFunc_lib.php


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