當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。