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


PHP ArrayHelper::array_diff_assoc_recursive方法代码示例

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


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

示例1: compareEntries

 /**
  * Gives status messages about the difference between 2 array elements
  * correponding to a collection entry in the database 
  *
  * @return array of message with their types
  */
 public static function compareEntries($entries, $type, $file, $where, $autoApply = false)
 {
     $msg = array();
     $arrayFromDataFolder = PHDB::getArrayFromDataFolder($file, $where);
     if (isset($entries[$type]["_id"])) {
         unset($entries[$type]["_id"]);
     }
     //testing existence
     if (!isset($entries[$type])) {
         array_push($msg, array("type" => "error", "msg" => "no {$type} in DB"));
         if ($autoApply) {
             PHDB::insert($file, $arrayFromDataFolder);
             array_push($msg, array("type" => "action", "msg" => "new {$type} inserted DB"));
             array_push($msg, array("type" => "ok", "msg" => "{$type} entry has been updated in Database, <br/>"));
         }
     } else {
         if ($diff = ArrayHelper::array_diff_assoc_recursive($arrayFromDataFolder, $entries[$type])) {
             array_push($msg, array("type" => "error", "msg" => "{$type} entry isn't up to date , some data has been 'added' to current content <br/>"));
             //var_dump($arrayFromDataFolder);
             //var_dump($entries[$type]);
             var_dump($diff);
             if (!empty($diff) && $autoApply) {
                 PHDB::remove($file, array($where["key"] => $where["value"]));
                 array_push($msg, array("type" => "action", "msg" => "old {$type} removed DB"));
                 PHDB::insert($file, $arrayFromDataFolder);
                 array_push($msg, array("type" => "action", "msg" => "new {$type} inserted DB"));
                 array_push($msg, array("type" => "ok", "msg" => "{$type} entry has been updated in Database, <br/>"));
             }
         } else {
             if ($diff = ArrayHelper::array_diff_assoc_recursive($entries[$type], $arrayFromDataFolder)) {
                 array_push($msg, array("type" => "error", "msg" => "{$type} entry isn't up to date , some data has been 'removed' from current content  <br/>"));
                 //var_dump($arrayFromDataFolder);
                 //var_dump($entries[$type]);
                 var_dump($diff);
                 if (!empty($diff) && $autoApply) {
                     PHDB::remove($file, array($where["key"] => $where["value"]));
                     array_push($msg, array("type" => "action", "msg" => "old {$type} removed DB"));
                     PHDB::insert($file, $arrayFromDataFolder);
                     array_push($msg, array("type" => "action", "msg" => "new {$type} inserted DB"));
                     array_push($msg, array("type" => "ok", "msg" => "{$type} entry has been updated in Database, <br/>"));
                 }
             } else {
                 array_push($msg, array("type" => "ok", "msg" => "nothing to update on {$type}"));
             }
         }
     }
     return $msg;
 }
开发者ID:Koulio,项目名称:pixelhumain,代码行数:54,代码来源:PHDB.php


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