且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从PHP多维数组删除重复值

更新时间:2023-02-23 09:56:27

array_unique 页面上的用户评论做一些线索这一点。你很可能会发现在这些意见的一些隐藏的宝石 - 它是一个非常方便的文档。

The user comments on the array_unique page do shed some light on this. You will most likely find some hidden gems in those comments - its a very handy documentation.

刚刚经历揭示了以下从一个多维数组中删除重复快速的浏览器:

Just a quick browser through revealed the following to remove duplicates from a multi dimensional array:

<?php
function super_unique($array)
{
  $result = array_map("unserialize", array_unique(array_map("serialize", $array)));

  foreach ($result as $key => $value)
  {
    if ( is_array($value) )
    {
      $result[$key] = super_unique($value);
    }
  }

  return $result;
}
?>