Home >Backend Development >PHP Tutorial >PHP multi-dimensional array removal of duplicate values example sharing_PHP tutorial
"rec_items": [
"{
"classes": "Fantasy",
"gid": 6326585,
"author": "I eat tomatoes",
"nid ": 10079306,
"last_sort": 841,
"last_chapter_name": "Volume 25, Chapter 6",
"sub_count": 5364424,
"novel_name" : "The Wilderness",
"last_update_time": 1393679718826
},
"classes": "Fantasy",
"gi d": 6109786,
"author" : "The Third Young Master of the Tang Family",
"nid": 10079046,
"last_sort": 1153,
"last_chapter_name": "Chapter 381 Starts Action (Part 2)",
" sub_count": 3933876,
"novel_name": "Peerless Tangmen",
"last_update_time": 1393681654511
},
{
"classes": "Fantasy",
" gid": 10645516,
"author": "陈东",
"nid": 12649548,
"last_sort": 478,
"last_chapter _name": "Chapter 432 Carry your wife back to the village",
"sub_count": 1422482,
"novel_name": "Perfect World",
"last_update_time": 1393681655610
},
“classes” {
: "Fantasy",
"gid": 4711723,
"author": "Just a little shrimp",
"nid": 12629406,
"last_sort": 26 03,
"last_chapter_name ": "Chapter 2588 Wake up! ",
"sub_count": 2841630,
"novel_name": "武Ni",
"last_update_time": 1393605899300
},
,
"gid": 3701669,
"author": "Cang Xiaotian",
"nid": 8583556,
"last_sort": 3427,
"last_chapter_name": "Chapter Chapter Two Thousand Two Hundred and Twenty-Five The Peacock King!",
"sub_count": 606473,
"novel_name": "武波九鄄",
"last_update_time": 1391279170831
},
",
"gid": 8141499,
"author": "风灵天下",
"nid": 9212380,
"last_sort": 2579,
"last_chapter_name": " Chapter 526: Nine Tribulations, Battle of the Heavenly Emperor [Seven]",
"sub_count": 3082857,
"novel_name": "Proud of the Nine Heavens",
"last_update_time": 1393677692614
}
],
"cate_book_items": [
{
"classes": "Fantasy",
"gid": 4711723,
"author": "Just a little shrimp ",
"nid": 12629406,
"last_sort": 2603,
"last_chapter_name": "Chapter 2588 Awakening! ",
"sub_count": 2841630,
"novel_name": "武Ni",
"last_update_time": 1393605899300
},
,
"gid": 3701669,
"author": "Cang Xiaotian",
"nid": 8583556,
"last_sort": 3427,
"last_chapter_name": "Chapter Chapter Two Thousand Two Hundred and Twenty-Five The Peacock King! ",
"sub_count": 606473,
"novel_name": "武波九鄄",
"last_update_time": 1391279170831
},
",
"gid": 10645516,
"author": "Chen Dong",
"nid": 12649548,
"last_sort": 478,
"last_chapter_name": "Chapter Chapter 432: Carrying the Wife Back to the Village",
"sub_count": 1422482,
"novel_name": "Perfect World",
"last_update_time": 1393681655610
}
]
}';
function mult_unique($array)
{
foreach($array as $key=>$v)
{
if(!in_array ($v, $return))
{
$return[$key]=$v;
}
}
return $return;
}
$json = get_object_vars(json_decode($json));
$data = $json['rec_items'];$data = array_merge_recursive($data, $json['cate_book_items']);
echo '
';
print_r($data);echo '
';print_r(mult_unique($data));
echo '< /pre>';
?>