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


PHP RecursiveArrayIterator::valid方法代码示例

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


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

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

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

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

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

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

示例7: RecursiveArrayIterator

        <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 == '^') {
                $_y--;
            }
开发者ID:jokuf,项目名称:solutions,代码行数:31,代码来源:points-solution.php

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

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

 public function getColumns($table = NULL)
 {
     if ($table === NULL) {
         throw new \Exception("Please input a table name. - glDbMysql.php - line 89");
     }
     if (!in_array($table, $this->getTables())) {
         throw new \Exception("The table you're trying to query does not exist - glDbMysql.php - line 91");
     }
     $dbh = $this->getDbh();
     $stmt = $dbh->prepare("DESCRIBE " . $table);
     $success = $stmt->execute();
     $columnNames = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $iterator = new \RecursiveArrayIterator($columnNames);
     $fields = array();
     if ($success !== FALSE) {
         while ($iterator->valid()) {
             if ($iterator->hasChildren()) {
                 $childIterator = new \RecursiveArrayIterator($iterator->current());
                 while ($childIterator->valid()) {
                     if ($childIterator->key() == "Field") {
                         array_push($fields, $childIterator->current());
                     }
                     $childIterator->next();
                 }
             }
             $iterator->next();
         }
         return $fields;
     }
     $error = array('query' => "DESCRIBE " . $table, 'errorInfo' => $this->prepareErrorInfo($dbh->errorInfo()));
     $errorInfo = json_encode($error);
     throw new MysqlException($errorInfo);
 }
开发者ID:shavez00,项目名称:groceryList,代码行数:33,代码来源:gldbmysql.php

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

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