PHP multidimensional array minus duplicate values

Source: Internet
Author: User
Tags json

  This article mainly introduces the PHP multidimensional array to remove duplicate value examples, the need for friends can refer to the following

  Code as follows: <?php $json = ' {      ' rec_items ': [        {      &NBS P     "Classes": "Fantasy"             "GID": 6326585,         &NBSP ;   "Author": "I eat tomatoes"             "nid": 10079306,           &N Bsp "Last_sort": 841,             "Last_chapter_name": "25th Volume sixth Chapter dispelled",       &N Bsp     "Sub_count": 5364424,             "Novel_name": "The Wild Wasteland",       &N Bsp     "Last_update_time": 1393679718826        },         {            "classes": "Fantasy"             "GID": 6109786,     &NBS P       "author": "Tanggu three Less",             "nid": 10079046,       &NB SP     "Last_sort": 1153,             "Last_chapter_name": "No. 381 chapter Start Action (middle)",             "Sub_count": 3933876,             "Novel_name": "The Peerless Tang Gate", & nbsp           "Last_update_time": 1393681654511        },       & nbsp {            "classes": "Fantasy"             "GID": 10645516, &N Bsp           "Author": "Chen Dong",             "nid": 12649548,   &NBSP ;         "Last_sort": 478,             "last_chapter_name": "No. 432 chapter carry daughter-in-law back Village,             "Sub_count": 1422482,             "Novel_name" : "Perfect World",             "Last_update_time": 1393681655610        , &nbsp ;      {            "classes": "Fantasy",           &NBSP ; "GID": 4711723,             "Author": "Just shrimp",        ,     "ni" D ": 12629406,            " Last_sort ": 2603,            " last _chapter_name ":" The No. 2588 Chapter wakes up! ",          " Sub_count ": 2841630,            " Novel_name ": "Wu-Mo",             "Last_update_time": 1393605899300        },   & nbsp     {          ' classes ': "Fantasy",             "GID" : 3701669,             "author": "Cang Laughs Day",      ,       "Nid": 858 3556,             "Last_sort": 3427,             "LAst_chapter_name ":" Chapter 2,225 Peacock King! ",          " Sub_count ": 606473,            " Novel_name ": "Wu Jiuxiao",             "Last_update_time": 1391279170831        },         {            "classes": "Fantasy",           &NBSP ; "GID": 8141499,             "Author": "The Wind is the world",             NID ": 9212380,            " Last_sort ": 2579,            " Last_c Hapter_name ":" No. 526 Chapter nine robbery, the war of the Emperor of Heaven "Seven" ",            " Sub_count ": 3082857,       & nbsp     "Novel_name": "Ao bougainvillea Day",             "Last_update_time": 1393677692614   &N Bsp    }    ],     "Cate_book_items": [        {&]nbsp           "classes": "Fantasy"             "GID": 4711723,   &NBSP ;         "Author": "Just shrimp",           "nid": 12629406,     &N Bsp       "Last_sort": 2603,             "Last_chapter_name": "The No. 2588 Chapter wakes up!" ",          " Sub_count ": 2841630,            " Novel_name ": "Wu-Mo",             "Last_update_time": 1393605899300        },   & nbsp     {          ' classes ': "Fantasy",             "GID" : 3701669,             "author": "Cang Laughs Day",      ,       "Nid": 858 3556,             "Last_sort": 3427,             Last_chapter _name ":" Part 2,200Bai Peacock King! ",          " Sub_count ": 606473,            " Novel_name ": "Wu Jiuxiao",             "Last_update_time": 1391279170831        },         {            "classes": "Fantasy",           &NBSP ; "GID": 10645516,             "Author": "Chen Dong",        ,     "Nid" : 12649548,             "Last_sort": 478,             LAST_CH Apter_name ":" No. 432 chapter carries daughter-in-law to return to village ",            " Sub_count ": 1422482,             "Novel_name": "Perfect World",             "Last_update_time": 1393681655610   &NB Sp    }    ]} ';   function Mult_unique ($array) {  $return = array ();   foreach ($array as $key => $v)   {    if (!in_array ($v, $return))     {      $return [$key]= $v;   &N Bsp }  }   return $return; }   $json = Get_object_vars (Json_decode ($json)); $data = $json [' Rec_items ']; $data = Array_merge_recursive ($data, $json [' Cate_book_items ']);   echo ' <pre> '; Print_r ($data); Echo ' <br> '; Print_r (Mult_unique ($data)); Echo ' </pre> ';?>  
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.