PHP multidimensional Array Remove duplicate Values example sharing _php instances

Source: Internet
Author: User
Copy CodeThe code is as follows:
$json = ' {

"Rec_items": [
{
"Classes": "Fantasy",
"GID": 6326585,
"Author": "I eat tomatoes",
"Nid": 10079306,
"Last_sort": 841,
"Last_chapter_name": "25th volume sixth chapter swept Away",
"Sub_count": 5364424,
"Novel_name": "Reckless and desolate",
"Last_update_time": 1393679718826
},
{
"Classes": "Fantasy",
"GID": 6109786,
"Author": "Tang Three Little",
"Nid": 10079046,
"Last_sort": 1153,
"Last_chapter_name": "The No. 381 chapter begins to act (middle)",
"Sub_count": 3933876,
"Novel_name": "The Peerless Tang Gate",
"Last_update_time": 1393681654511
},
{
"Classes": "Fantasy",
"GID": 10645516,
"Author": "Chen Dong",
"Nid": 12649548,
"Last_sort": 478,
"Last_chapter_name": "The No. 432 chapter carries the daughter-in-law 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": "The No. 2588 Chapter wakes up!" ",
"Sub_count": 2841630,
"Novel_name": "Wu Inverse",
"Last_update_time": 1393605899300
},
{
"Classes": "Fantasy",
"GID": 3701669,
"Author": "Pale Smile Day",
"Nid": 8583556,
"Last_sort": 3427,
"Last_chapter_name": "Chapter 2,225 Peacock King!" ",
"Sub_count": 606473,
"Novel_name": "Wu broken Nine",
"Last_update_time": 1391279170831
},
{
"Classes": "Fantasy",
"GID": 8141499,
"Author": "Wind The World",
"Nid": 9212380,
"Last_sort": 2579,
"Last_chapter_name": "The No. 526 Chapter nine robbery, the war of the Emperor" Seven ",
"Sub_count": 3082857,
"Novel_name": "Proud Kokonoe days",
"Last_update_time": 1393677692614
}
],
"Cate_book_items": [
{
"Classes": "Fantasy",
"GID": 4711723,
"Author": "Just a little shrimp",
"Nid": 12629406,
"Last_sort": 2603,
"Last_chapter_name": "The No. 2588 Chapter wakes up!" ",
"Sub_count": 2841630,
"Novel_name": "Wu Inverse",
"Last_update_time": 1393605899300
},
{
"Classes": "Fantasy",
"GID": 3701669,
"Author": "Pale Smile Day",
"Nid": 8583556,
"Last_sort": 3427,
"Last_chapter_name": "Chapter 2,225 Peacock King!" ",
"Sub_count": 606473,
"Novel_name": "Wu broken Nine",
"Last_update_time": 1391279170831
},
{
"Classes": "Fantasy",
"GID": 10645516,
"Author": "Chen Dong",
"Nid": 12649548,
"Last_sort": 478,
"Last_chapter_name": "The No. 432 chapter carries the daughter-in-law 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 '

';
Print_r ($data);
Echo '
';
Print_r (Mult_unique ($data));
Echo '
';
?>
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.