PHP 二维数据去重

         $tj_recommend = [
            ['id' => 1, 'files_id' => 1],
            ['id' => 2, 'files_id' => 3],
            ['id' => 3, 'files_id' => 3],
            ['id' => 4, 'files_id' => 2],
            ['id' => 5, 'files_id' => 5],
            ['id' => 6, 'files_id' => 1],
            ['id' => 7, 'files_id' => 7],
            ['id' => 8, 'files_id' => 8],
            ['id' => 9, 'files_id' => 1]
        ];
        $arr = [];
        foreach($tj_recommend as $item){
            if(!in_array($item['files_id'], array_column($arr, 'files_id'))){
                $arr[] = $item;
            }
        }
        print_r($arr);exit;

34 thoughts on “PHP 二维数据去重”

  1. Hello there, I discovered your web site via Google at the same time as searching for a comparable matter, your website got here up, it looks great. I have bookmarked it in my google bookmarks.

  2. Hello, i believe that i saw you visited my website thus i came to “go back the prefer”.I am attempting to find things to improve my web site!I guess its adequate to make use of some of your concepts!!

  3. An impressive share, I simply given this onto a colleague who was doing a little analysis on this. And he actually purchased me breakfast because I discovered it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to debate this, I really feel strongly about it and love reading extra on this topic. If potential, as you turn into experience, would you thoughts updating your weblog with more details? It’s extremely helpful for me. Big thumb up for this blog post!

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Back To Top

鄂ICP备17008157号-1