本文整理匯總了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;
}