我創建一個日誌文件,在其中我想顯示舊條目和更新的條目都在一起,但沿着這些我也想強調在新條目的變化,喜歡它的當我們編輯他們突出顯示編輯過的部分的問題時,在計算器中完成。比較兩個不同的多維數組和突出的變化
正如你可以看到有在描述的不同,還有許多其他的指標,我只是展示其中的一些。
我有一個看起來像這樣兩個不同的陣列:
新條目
Array
(
[0] => stdClass Object
(
[business_logo] => 31190_photo.jpg
[business] => Sms Factory Powered By Bds Technologies Pvt Ltd
[b_discription] => We smsfactory are world's leading SMS messaging provider offering remarakable and reliable SMS Text and Voice messaging globally through almost all-networks of mobile phones successfully. You may contact-us anytime for making any query. Our Services are very useful economically as well as eco-friendly,
[mod_date] => 1467736200
)
)
舊條目
Array
(
[0] => stdClass Object
(
[business_logo] => 31190_photo.jpg
[business] => Sms Factory Powered By Bds Technologies Pvt Ltd
[b_discription] => We smsfactory are world's leading SMS messaging provider offering remarakable and reliable SMS Text and Voice messaging globally through almost all-networks of mobile phones successfully. You may contact-us anytime for making any query. Our Services are very useful economically as well as eco-friendly, which enables you to send simultaneous bulk sms to your targeted Customers, Regular-Customers, Buyers, Shoppers, Fans, Regular-shoppers, Clients, Clientele, Members, Managers, Supervisors, Fieldworkers, Graduates, Post graduates, Technicians, Public, Citizens, Mobile-Users, Viewers, Future-purchasers, Users, End-users, Students, Job-seekers, Enjoyers, Visitors, Frequent-visitors, Persons, Individuals, Frequenter, Obtainers, Receivers, Assignees, Recipients, Travelers, Tourists, Guys, Persons, Men and Women, Spectators, Technicians, Staff, Workers, Recruiters, Newcomers, Representatives, Dealers, Distributors, Followers, Shareholders, Investors, Bondholders, Shareowners, Financiers, Bankers, Participants, Associates, Assistants, Colleagues, Contributors, Helpers, Partakers, Party, Sharers, Supporters, Admirers, Devotees, Groupies, Enthusiasts and many more.
[mod_date] => 1467736200
)
)
我做這個研究,發現大量的功能,從中我曾經嘗試這樣做:
function arrayRecursiveDiff($aArray1, $aArray2) {
$aReturn = array();
foreach ($aArray1 as $mKey => $mValue) {
if (array_key_exists($mKey, $aArray2)) {
if (is_array($mValue)) {
$aRecursiveDiff = arrayRecursiveDiff($mValue, $aArray2[$mKey]);
if (count($aRecursiveDiff)) { $aReturn[$mKey] = $aRecursiveDiff; }
} else {
if ($mValue != $aArray2[$mKey]) {
$aReturn[$mKey] = $mValue;
}
}
} else {
$aReturn[$mKey] = $mValue;
}
}
return $aReturn;
}
$arr1 = arrayRecursiveDiff($newentry,$oldentry);
但它只顯示我沒有任何比較的新條目。希望我已經很好地解釋了我的問題。
哪些屬性是你期待有所不同,'只有b_discription'或整個對象? [這個類提供了一個差異比較](http://code.stephenmorley.org/php/diff-implementation/),就像你會遇到源代碼修訂系統一樣。 – mulquin
我想比較整個數組值,所以我可以突出顯示新 –
是類似的東西,你顯示的鏈接 –