Suitable for merging arrays and removing duplicate arrays. Mark yourself www.appleshu.com
- $json='{
- "rec_items": [
- {
- "classes": "Fantasy",
- "gid": 6326585,
- "author": "I eat tomatoes",
- "nid": 10079306,
- "last_sort": 841,
- "last_chapter_name": "Chapter 6 of Volume 25 Swept Away",
- "sub_count": 5364424,
- "novel_name": "The Wilderness ",
- "last_update_time": 1393679718826
- },
- {
- "classes": "Fantasy",
- "gid": 6109786,
- "author": "Tang Jia San Shao",
- "nid": 10079046,
- "last_sort" : 1153,
- "last_chapter_name": "Chapter 381 Begins Action (Part 2)",
- "sub_count": 3933876,
- "novel_name": "Peerless Tang Sect",
- "last_update_time": 1393681654511
- },
- {
- "classes": "Fantasy",
- "gid": 10645516,
- "author": "Chen Dong",
- "nid": 12649548,
- "last_sort": 478,
- "last_chapter_name": "Fourth Chapter 132: Carrying the 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": 2603,
- "last_chapter_name": "Chapter 2588 Wake up! ",
- "sub_count": 2841630,
- "novel_name": "武Ni",
- "last_update_time": 1393605899300
- },
- {
- "classes": "fantasy",
- "gid": 3701669,
- "author" : "Cang Xiaotian",
- "nid": 8583556,
- "last_sort": 3427,
- "last_chapter_name": "Chapter 2225 The Peacock King! ",
- "sub_count": 606473,
- "novel_name": "武波九鄄",
- "last_update_time": 1391279170831
- },
- {
- "classes": "fantasy",
- "gid": 8141499,
- "author ": "Feng Ling Tian Xia",
- "nid": 9212380,
- "last_sort": 2579,
- "last_chapter_name": "Chapter 526 Nine Tribulations, Battle of the Emperor of Heaven [Seven]",
- "sub_count" : 3082857, 2 "NOVEL_NAME": "Ao Shi Nine Heaven",
- "Last_update_time": 1393677692614
- }
- ],
- "Cate_Book_items": [
- {
- "" fantasy ",
- " gid ": 47777 11723,, "author": "Just a little shrimp",
- "nid": 12629406,
- "last_sort": 2603,
- "last_chapter_name": "Chapter 2588 Wake up! ",
- "sub_count": 2841630,
- "novel_name": "武Ni",
- "last_update_time": 1393605899300
- },
- {
- "classes": "fantasy",
- "gid": 3701669,
- "author" : "Cang Xiaotian",
- "nid": 8583556,
- "last_sort": 3427,
- "last_chapter_name": "Chapter 2225 The Peacock King!",
- "sub_count": 606473,
- "novel_name": "武波九鄄",
- "last_update_time": 1391279170831
- },
- {
- "classes": "Fantasy",
- "gid": 10645516,
- "author ": "Chen Dong",
- "nid": 12649548,
- "last_sort": 478,
- "last_chapter_name": "Chapter 432 Carrying the Wife Back to the Village",
- "sub_count": 1422482,
- "novel_name ": "Perfect World",
- "last_update_time": 1393681655610
- }
- ]
- }';
- function mult_unique($array)
- {
- $return = 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 '
';</li>
<li>print_r($ data);</li>
<li>echo '<br>';</li>
<li>print_r(mult_unique($data));</li>
<li>echo ' ';
- ?>
Copy code
|