PHP多次元配列から重複値を削除する例の共有_PHPチュートリアル

WBOY
リリース: 2016-07-13 10:36:58
オリジナル
882 人が閲覧しました

コードをコピーします コードは次のとおりです:

$json='{

"rec_items": [
" "classes": "ファンタジー",
"gid": 6326585,
"author": "私はトマトを食べます",
"nid": 10079306,
"last_sort": 841,
" last_chapter_name": "第 25 巻、第 6 章、一掃"、
"sub_count": 5364424,
" classes": "ファンタジー",
"gid": 6109786,
"著者": "Tang Jia San Shao",
"nid": 10079046,
"last_sort": 1153,
"last_chapter_name": "381 章行動開始 (パート 2)",
"sub_count": 3933876,
"novel_name": "無双の唐人",
"last_update_time" : 1393681654511
},
"クラス": "ファンタジー",
"gid" : 10645516,
"著者": "Chen Dong",
"nid": "last_sort": 478,
"last_chapter_name": "第432話 妻、村に帰る",
"sub_count" : 1422482,
"novel_name": "パーフェクトワールド",
"last_update_time" 1393681655610
「ファンタジー」、
"gid": 4711723、
"author": "ちょっとエビ" "nid": 12629406,
"last_sort": 2603,
"last_chapter_name": "第 2588 章 覚醒! ",
"sub_count": 2841630,
"novel_name": "武Ni",
"last_update_time": 1393605899300
},
{
"classes": "Fantasy",
"gid": 69、
「著者」 : "Cang Xiaotian",
"nid": 8583556,
"last_sort": 3427,
"last_chapter_name": "第 2225 章 孔雀王!",
"sub_count": 606473,
"novel_name": "武波九鄄",
"last_update_time": 1391279170831
},
"classes": "fantasy",
"gid": 8141499,
"author " : "風霊天霞",
"nid": 9212380,
"last_sort": 2579,
"last_chapter_name": "第526章 九つの艱難、天帝の戦い【七】",
" "sub_count" : 3082857,
「小説名」: 「classes」: "Fantasy"、
"gid": 4711723、
"author": "ちょっとしたエビ"、
"nid": 12629406、
"last_sort": 2603、
" last_chapter_name": "第2588章覚醒! ",
"sub_count": 2841630,
"novel_name": "武Ni",
"last_update_time": 1393605899300
},
{
"classes": "Fantasy",
"gid": 69、
「著者」 : "Cang Xiaotian",
"nid": 8583556,
"last_sort": 3427,
"last_chapter_name": "第 2225 章 孔雀王! ",
"sub_count": 606473,
"novel_name": "武波九鄄",
"last_update_time": 1391279170831
},
"classes": "fantasy",
"gid": 10645516,
"author " : "チェンドン",
"nid": 12649548,
"last_sort": 478,
"last_chapter_name": "第 432 章 妻を村に連れて帰る",
"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 '

';<br>print_r($data);<br>echo '<br>';</p>print_r(mult_unique($data));<p>echo '
';
?>

www.bkjia.com本当http://www.bkjia.com/PHPjc/736828.html技術記事次のようにコードをコピーします: ?php $json='{ "rec_items": [ { "classes": "Fantasy", "gid": 6326585, "author": "I Eat Tomatoes", "nid": 10079306, " last_sort ": 841, "last_chapter_name":...
関連ラベル:
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!