php多維陣列去掉重複值樣本分享_PHP教程

來源:互聯網
上載者:User
複製代碼 代碼如下:
$json='{

"rec_items": [
{
"classes": "玄幻",
"gid": 6326585,
"author": "我吃西紅柿",
"nid": 10079306,
"last_sort": 841,
"last_chapter_name": "第二十五卷 第六章 一掃而空",
"sub_count": 5364424,
"novel_name": "莽荒紀",
"last_update_time": 1393679718826
},
{
"classes": "玄幻",
"gid": 6109786,
"author": "唐家三少",
"nid": 10079046,
"last_sort": 1153,
"last_chapter_name": "第三百八十一章 開始行動(中)",
"sub_count": 3933876,
"novel_name": "絕世唐門",
"last_update_time": 1393681654511
},
{
"classes": "玄幻",
"gid": 10645516,
"author": "辰東",
"nid": 12649548,
"last_sort": 478,
"last_chapter_name": "第四百三十二章 扛媳婦回村",
"sub_count": 1422482,
"novel_name": "完美世界",
"last_update_time": 1393681655610
},
{
"classes": "玄幻",
"gid": 4711723,
"author": "只是小蝦米",
"nid": 12629406,
"last_sort": 2603,
"last_chapter_name": "第2588章 蘇醒!",
"sub_count": 2841630,
"novel_name": "武逆",
"last_update_time": 1393605899300
},
{
"classes": "玄幻",
"gid": 3701669,
"author": "蒼笑天",
"nid": 8583556,
"last_sort": 3427,
"last_chapter_name": "第兩千兩百二十五章 孔雀王!",
"sub_count": 606473,
"novel_name": "武破九霄",
"last_update_time": 1391279170831
},
{
"classes": "玄幻",
"gid": 8141499,
"author": "風淩天下",
"nid": 9212380,
"last_sort": 2579,
"last_chapter_name": "第五百二十六章 九劫、天帝之戰【七】",
"sub_count": 3082857,
"novel_name": "傲世九重天",
"last_update_time": 1393677692614
}
],
"cate_book_items": [
{
"classes": "玄幻",
"gid": 4711723,
"author": "只是小蝦米",
"nid": 12629406,
"last_sort": 2603,
"last_chapter_name": "第2588章 蘇醒!",
"sub_count": 2841630,
"novel_name": "武逆",
"last_update_time": 1393605899300
},
{
"classes": "玄幻",
"gid": 3701669,
"author": "蒼笑天",
"nid": 8583556,
"last_sort": 3427,
"last_chapter_name": "第兩千兩百二十五章 孔雀王!",
"sub_count": 606473,
"novel_name": "武破九霄",
"last_update_time": 1391279170831
},
{
"classes": "玄幻",
"gid": 10645516,
"author": "辰東",
"nid": 12649548,
"last_sort": 478,
"last_chapter_name": "第四百三十二章 扛媳婦回村",
"sub_count": 1422482,
"novel_name": "完美世界",
"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 '
';
?>

http://www.bkjia.com/PHPjc/736828.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/736828.htmlTechArticle複製代碼 代碼如下: ?php $json='{ "rec_items": [ { "classes": "玄幻", "gid": 6326585, "author": "我吃西紅柿", "nid": 10079306, "last_sort": 841, "last_chapter_name":...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.