Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official

Recommended Posts

在做PHP开发,查询出来的并集通常会需要做根据某一个键来去重,下面是具体方法:

// 去重
public function duplicate($list,$key)
{
    $result = [];
    $keys = [];
    foreach($list as $item){
        if(!in_array($item[$key],$keys)){
            array_push($result,$item);
            array_push($keys,$item[$key]);
        }
    }
    return $result;
}

使用:

$this->duplicate($group,'group');

处理根据字段去重的优化操作是在查询的时候,可以根据这个键来做【分组】即可完美避免这个问题。

Link to post
Link to comment
Share on other sites

 Share

discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...