当前位置: 首页>>代码示例>>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;未经允许,请勿转载。