Example of removing duplicate values from the php multi-dimensional array. Copy the code as follows :? Php $ json {rec_items: [{classes: Fantasy, gid: 6326585, author: I eat tomatoes, nid: 10079306, last_sort: 841, last_chapter_name:
The code is as follows:
$ Json = '{
"Rec_items ":[
{
"Classes": "Fantasy ",
"Gid": 6326585,
"Author": "I eat tomatoes ",
"Nid": 10079306,
"Last_sort": 841,
"Last_chapter_name": "Chapter 6 of volume 25th ",
"Sub_count": 5364424,
"Novel_name": "Old Man ",
"Last_update_time": 1393679718826
},
{
"Classes": "Fantasy ",
"Gid": 6109786,
"Author": "Tang Jia San Shao ",
"Nid": 10079046,
"Last_sort": 1153,
"Last_chapter_name": "Chapter 381st starting action (in )",
"Sub_count": 3933876,
"Novel_name": "peerless tangmen ",
"Last_update_time": 1393681654511
},
{
"Classes": "Fantasy ",
"Gid": 10645516,
"Author": "Chen Dong ",
"Nid": 12649548,
"Last_sort": 478,
"Last_chapter_name": "Chapter 432nd returning daughter-in-law to the village ",
"Sub_count": 1422482,
"Novel_name": "Perfect World ",
"Last_update_time": 1393681655610
},
{
"Classes": "Fantasy ",
"Gid": 4711723,
"Author": "Only shrimp ",
"Nid": 12629406,
"Last_sort": 2603,
"Last_chapter_name": "Chapter 1 awakening! ",
"Sub_count": 2841630,
"Novel_name": "",
"Last_update_time": 1393605899300
},
{
"Classes": "Fantasy ",
"Gid": 3701669,
"Author": "Cang Xiaotian ",
"Nid": 8583556,
"Last_sort": 3427,
"Last_chapter_name": "Chapter 2225th Peacock King! ",
"Sub_count": 606473,
"Novel_name": "Wu qijiu Xiao ",
"Last_update_time": 1391279170831
},
{
"Classes": "Fantasy ",
"Gid": 8141499,
"Author": "Feng Lingxia ",
"Nid": 9212380,
"Last_sort": 2579,
"Last_chapter_name": "Chapter 7 ]",
"Sub_count": 3082857,
"Novel_name": "unique day ",
"Last_update_time": 1393677692614
}
],
"Cate_book_items ":[
{
"Classes": "Fantasy ",
"Gid": 4711723,
"Author": "Only shrimp ",
"Nid": 12629406,
"Last_sort": 2603,
"Last_chapter_name": "Chapter 1 awakening! ",
"Sub_count": 2841630,
"Novel_name": "",
"Last_update_time": 1393605899300
},
{
"Classes": "Fantasy ",
"Gid": 3701669,
"Author": "Cang Xiaotian ",
"Nid": 8583556,
"Last_sort": 3427,
"Last_chapter_name": "Chapter 2225th Peacock King! ",
"Sub_count": 606473,
"Novel_name": "Wu qijiu Xiao ",
"Last_update_time": 1391279170831
},
{
"Classes": "Fantasy ",
"Gid": 10645516,
"Author": "Chen Dong ",
"Nid": 12649548,
"Last_sort": 478,
"Last_chapter_name": "Chapter 432nd returning daughter-in-law 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'
';
print_r($data);
echo '
';
print_r(mult_unique($data));
echo '
';
?>
The http://www.bkjia.com/PHPjc/736828.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/736828.htmlTechArticle code is as follows :? Php $ json = '{"rec_items": [{"classes": "Fantasy", "gid": 6326585, "author": "My Tomato", "nid ": 10079306, "last_sort": 841, "last_chapter_name ":...