本文整理汇总了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;
}