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


PHP XMLWriter::getDepth方法代码示例

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


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

示例1: _serialize

 /**
  * Utilize custom serialization for XMLWriter object, to convert object
  * to SQL.
  *
  * @return string
  */
 private function _serialize()
 {
     $this->setIndent(true);
     $this->setIndentString(' ');
     $this->startDocument('1.0', 'UTF-8');
     $this->_namespaces = array();
     $this->_tagStack = array();
     $this->_state = array();
     $this->_type = 'Tag';
     $this->_expectedDepth = 0;
     $this->_lastkey = array();
     $lastdepth = 0;
     foreach ($this->_iter = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->_array), \RecursiveIteratorIterator::SELF_FIRST) as $key => $values) {
         $depth = $this->_iter->getDepth();
         while ($depth < $this->_expectedDepth) {
             // finished with this tag
             $this->_finish($key, $values);
             $lastdepth--;
         }
         if (isset($this->_lastkey[$depth]) && $key != $this->_lastkey[$depth]) {
             while ($lastdepth > $depth) {
                 $this->_finish($key, $values);
                 $lastdepth--;
             }
         }
         $this->_lastkey[$depth] = $key;
         foreach ($this->_lastkey as $d => &$k) {
             if ($d > $depth) {
                 $k = false;
             }
         }
         $this->_lastkey = array_filter($this->_lastkey, array('Pyrus\\XMLWriter', '_filter'));
         $lastdepth = $depth;
         if ($this->_type !== 'Attribs') {
             if ($key === '_content') {
                 $this->text($values);
                 continue;
             }
             if ($key === 'attribs') {
                 // attributes are 1 depth higher
                 $this->_pushState();
                 $this->_expectedDepth = $this->_iter->getDepth() + 1;
                 $this->_type = 'Attribs';
                 // cycle to first attribute
                 continue;
             }
         }
         $next = '_handle' . $this->_type;
         while ($next = $this->{$next}($key, $values)) {
         }
     }
     while ($lastdepth) {
         $this->_finish($key, $values);
         $lastdepth--;
     }
     $this->endDocument();
     return $this->flush();
 }
开发者ID:peopleplan,项目名称:Pyrus,代码行数:64,代码来源:XMLWriter.php


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