當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Spyc::flatten方法代碼示例

本文整理匯總了PHP中Spyc::flatten方法的典型用法代碼示例。如果您正苦於以下問題:PHP Spyc::flatten方法的具體用法?PHP Spyc::flatten怎麽用?PHP Spyc::flatten使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Spyc的用法示例。


在下文中一共展示了Spyc::flatten方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addArray

 function addArray($array, $indent)
 {
     $key = key($array);
     if (!isset($array[$key])) {
         return false;
     }
     if ($array[$key] === array()) {
         $array[$key] = '';
     }
     $value = $array[$key];
     // Unfolding inner array tree as defined in $this->_arrpath.
     //$_arr = $this->result; $_tree[0] = $_arr; $i = 1;
     $tempPath = Spyc::flatten($this->path);
     eval('$_arr = $this->result' . $tempPath . ';');
     if ($this->_containsGroupAlias) {
         do {
             if (!isset($this->SavedGroups[$this->_containsGroupAlias])) {
                 echo "Bad group name: {$this->_containsGroupAlias}.";
                 break;
             }
             $groupPath = $this->SavedGroups[$this->_containsGroupAlias];
             eval('$value = $this->result' . Spyc::flatten($groupPath) . ';');
         } while (false);
         $this->_containsGroupAlias = false;
     }
     // Adding string or numeric key to the innermost level or $this->arr.
     if ($key) {
         $_arr[$key] = $value;
     } else {
         if (!is_array($_arr)) {
             $_arr = array($value);
             $key = 0;
         } else {
             $_arr[] = $value;
             end($_arr);
             $key = key($_arr);
         }
     }
     $this->path[$indent] = $key;
     eval('$this->result' . $tempPath . ' = $_arr;');
     if ($this->_containsGroupAnchor) {
         $this->SavedGroups[$this->_containsGroupAnchor] = $this->path;
         $this->_containsGroupAnchor = false;
     }
 }
開發者ID:Debenson,項目名稱:openwan,代碼行數:45,代碼來源:spyc.php

示例2: addArray

 private function addArray($array, $indent)
 {
     if (count($array) > 1) {
         return $this->addArrayInline($array, $indent);
     }
     $key = key($array);
     if (!isset($array[$key])) {
         return false;
     }
     $value = $array[$key];
     $tempPath = Spyc::flatten($this->path);
     // Unfolding inner array tree.
     $_arr = $this->result;
     foreach ($this->path as $k) {
         $_arr = $_arr[$k];
     }
     if ($this->_containsGroupAlias) {
         do {
             if (!isset($this->SavedGroups[$this->_containsGroupAlias])) {
                 echo "Bad group name: {$this->_containsGroupAlias}.";
                 break;
             }
             $groupPath = $this->SavedGroups[$this->_containsGroupAlias];
             $value = $this->result;
             foreach ($groupPath as $k) {
                 $value = $value[$k];
             }
         } while (false);
         $this->_containsGroupAlias = false;
     }
     // Adding string or numeric key to the innermost level or $this->arr.
     if ($key) {
         $_arr[$key] = $value;
     } else {
         if (!is_array($_arr)) {
             $_arr = array($value);
             $key = 0;
         } else {
             $_arr[] = $value;
             end($_arr);
             $key = key($_arr);
         }
     }
     $this->path[$indent] = $key;
     eval('$this->result' . $tempPath . ' = $_arr;');
     if ($this->_containsGroupAnchor) {
         $this->SavedGroups[$this->_containsGroupAnchor] = $this->path;
         $this->_containsGroupAnchor = false;
     }
 }
開發者ID:postpostmodern,項目名稱:phooey,代碼行數:50,代碼來源:spyc.php


注:本文中的Spyc::flatten方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。