• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php多维数组去掉重复值示例分享_php实例

php 搞代码 4年前 (2022-01-25) 12次浏览 已收录 0个评论
<?php<BR>$json='{</P><P>    "rec_items": [<BR>        {<BR>            "classes": "玄幻",<BR>            "gid": 6326585,<BR>            "author": "我吃西红柿",<BR>            "nid": 10079306,<BR>            "last_sort": 841,<BR>            "last_chapter_name": "第二十五卷 第六章 一扫而空",<BR>            "sub_count": 5364424,<BR>            "novel_name": "莽荒纪",<BR>            "last_update_time": 1393679718826<BR>        },<BR>        {<BR>            "classes": "玄幻",<BR>            "gid": 6109786,<BR>            "author": "唐家三少",<BR>            "nid": 10079046,<BR>            "last_sort": 1153,<BR>            "last_chapter_name": "第三百八十一章 开始行动(中)",<BR>            "sub_count": 3933876,<BR>            "novel_name": "绝世唐门",<BR>            "last_update_time": 1393681654511<BR>        },<BR>        {<BR>            "classes": "玄幻",<BR>            "gid": 10645516,<BR>            "author": "辰东"<em>¥本文来%源[email protected]搞@^&代*@码)网5</em><strong>搞gaodaima代码</strong>,<BR>            "nid": 12649548,<BR>            "last_sort": 478,<BR>            "last_chapter_name": "第四百三十二章 扛媳妇回村",<BR>            "sub_count": 1422482,<BR>            "novel_name": "完美世界",<BR>            "last_update_time": 1393681655610<BR>        },<BR>        {<BR>            "classes": "玄幻",<BR>            "gid": 4711723,<BR>            "author": "只是小虾米",<BR>            "nid": 12629406,<BR>            "last_sort": 2603,<BR>            "last_chapter_name": "第2588章 苏醒!",<BR>            "sub_count": 2841630,<BR>            "novel_name": "武逆",<BR>            "last_update_time": 1393605899300<BR>        },<BR>        {<BR>            "classes": "玄幻",<BR>            "gid": 3701669,<BR>            "author": "苍笑天",<BR>            "nid": 8583556,<BR>            "last_sort": 3427,<BR>            "last_chapter_name": "第两千两百二十五章 孔雀王!",<BR>            "sub_count": 606473,<BR>            "novel_name": "武破九霄",<BR>            "last_update_time": 1391279170831<BR>        },<BR>        {<BR>            "classes": "玄幻",<BR>            "gid": 8141499,<BR>            "author": "风凌天下",<BR>            "nid": 9212380,<BR>            "last_sort": 2579,<BR>            "last_chapter_name": "第五百二十六章 九劫、天帝之战【七】",<BR>            "sub_count": 3082857,<BR>            "novel_name": "傲世九重天",<BR>            "last_update_time": 1393677692614<BR>        }<BR>    ],<BR>    "cate_book_items": [<BR>        {<BR>            "classes": "玄幻",<BR>            "gid": 4711723,<BR>            "author": "只是小虾米",<BR>            "nid": 12629406,<BR>            "last_sort": 2603,<BR>            "last_chapter_name": "第2588章 苏醒!",<BR>            "sub_count": 2841630,<BR>            "novel_name": "武逆",<BR>            "last_update_time": 1393605899300<BR>        },<BR>        {<BR>            "classes": "玄幻",<BR>            "gid": 3701669,<BR>            "author": "苍笑天",<BR>            "nid": 8583556,<BR>            "last_sort": 3427,<BR>            "last_chapter_name": "第两千两百二十五章 孔雀王!",<BR>            "sub_count": 606473,<BR>            "novel_name": "武破九霄",<BR>            "last_update_time": 1391279170831<BR>        },<BR>        {<BR>            "classes": "玄幻",<BR>            "gid": 10645516,<BR>            "author": "辰东",<BR>            "nid": 12649548,<BR>            "last_sort": 478,<BR>            "last_chapter_name": "第四百三十二章 扛媳妇回村",<BR>            "sub_count": 1422482,<BR>            "novel_name": "完美世界",<BR>            "last_update_time": 1393681655610<BR>        }<BR>    ]<BR>}';</P><P>function mult_unique($array)<BR>{<BR>  $return = array();<BR>  foreach($array as $key=>$v)<BR>  {<BR>    if(!in_array($v, $return))<BR>    {<BR>      $return[$key]=$v;<BR>    }<BR>  }<BR>  return $return;<BR>}</P><P>$json = get_object_vars(json_decode($json));<BR>$data = $json['rec_items'];<BR>$data = array_merge_recursive($data, $json['cate_book_items']);</P><P>echo '<pre class="prettyprint linenums">';<BR>print_r($data);<BR>echo '<br>';<BR>print_r(mult_unique($data));<BR>echo '

‘;
?>


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php多维数组去掉重复值示例分享_php实例
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址