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


PHP Tools::atk_array_merge_recursive方法代碼示例

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


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

示例1: _stackscope


//.........這裏部分代碼省略.........
                 }
             }
         }
         if (isset($stack[$this->atklevel])) {
             $currentitem = $stack[$this->atklevel];
         }
         if (!isset($currentitem) || $currentitem == '') {
             Tools::atkdebug('New level on session stack');
             // Initialise
             $currentitem = [];
             // new level.. always based on the previous level
             if (isset($stack[count($stack) - 1])) {
                 $copieditem = $stack[count($stack) - 1];
             }
             if (isset($copieditem) && is_array($copieditem)) {
                 foreach ($copieditem as $key => $value) {
                     if (in_array($key, $sessionVars) || isset($copieditem['defined_stackvars']) && is_array($copieditem['defined_stackvars']) && in_array($key, $copieditem['defined_stackvars'])) {
                         $currentitem[$key] = $value;
                     }
                 }
                 if (isset($copieditem['defined_stackvars'])) {
                     $currentitem['defined_stackvars'] = $copieditem['defined_stackvars'];
                 }
             }
             // Posted vars always overwrite anything in the current session..
             foreach (array_merge($pageVars, $sessionVars) as $var) {
                 $recursive = $var[strlen($var) - 1] == '*';
                 $var = $recursive ? substr($var, 0, -1) : $var;
                 if (isset($postvars[$var]) && $postvars[$var] != '') {
                     if ($postvars[$var] == 'clear') {
                         $currentitem[$var] = '';
                     } else {
                         if ($recursive && is_array($currentitem[$var]) && is_array($postvars[$var])) {
                             $currentitem[$var] = array_merge_recursive($currentitem[$var], $postvars[$var]);
                         } else {
                             $currentitem[$var] = $postvars[$var];
                         }
                     }
                 }
             }
             array_push($stack, $currentitem);
         } else {
             // Stay at the current level..
             // If we are getting back from a higher level, we may now delete everything above
             $deletecount = count($stack) - 1 - $this->atklevel;
             for ($i = 0; $i < $deletecount; ++$i) {
                 Tools::atkdebug('popped an item out of the stack');
                 array_pop($stack);
             }
             foreach ($pageVars as $var) {
                 $recursive = $var[strlen($var) - 1] == '*';
                 $var = $recursive ? substr($var, 0, -1) : $var;
                 if (isset($postvars[$var]) && count($postvars[$var]) > 0 && (!$partial || !in_array($var, $lockedVars))) {
                     if ($recursive && isset($currentitem[$var]) && is_array($currentitem[$var]) && is_array($postvars[$var])) {
                         $currentitem[$var] = Tools::atk_array_merge_recursive($currentitem[$var], $postvars[$var]);
                     } else {
                         $currentitem[$var] = $postvars[$var];
                     }
                 }
             }
             // page vars must overwrite the current stack..
             $stack[$this->atklevel] =& $currentitem;
             // session vars need not be remembered..
             foreach ($sessionVars as $var) {
                 if (isset($postvars[$var]) && count($postvars[$var]) > 0 && (!$partial || !in_array($var, $lockedVars))) {
                     $currentitem[$var] = $postvars[$var];
                 }
             }
         }
         if (isset($currentitem['atkformdata']) && is_array($currentitem['atkformdata'])) {
             Tools::atkdebug('Session formdata present');
             foreach ($currentitem['atkformdata'] as $var => $value) {
                 // don't override what was passed in the url.
                 if (!isset($postvars[$var])) {
                     $postvars[$var] = $value;
                 } else {
                     if (is_array($postvars[$var]) && is_array($value)) {
                         // Formdata that was posted earlier needs to be merged with the current
                         // formdata. We use a custom array_merge here to preserve key=>value pairs.
                         $postvars[$var] = Tools::atk_array_merge_keys($value, $postvars[$var]);
                     }
                 }
             }
             // We leave atkformdata in the current stack entry untouched so that
             // when the stack might be forked of whatsoever the form data is still
             // present. However, this data should not be directly accessed in the node!
         }
         if (is_array($currentitem)) {
             foreach ($currentitem as $var => $value) {
                 $recursive = in_array("{$var}*", $pageVars);
                 // don't override what was passed in the url except for
                 // recursive mergeable pagevars
                 if ($recursive || !isset($postvars[$var])) {
                     $postvars[$var] = $value;
                 }
             }
         }
     }
     // end if atkescape
 }
開發者ID:sintattica,項目名稱:atk,代碼行數:101,代碼來源:SessionManager.php


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