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. I am not sure the place you’re getting your information, however great topic. I must spend a while studying more or figuring out more. Thanks for great info I was looking for this info for my mission.

  2. Greetings from Los angeles! I’m bored to death at work so I decided to browse your site on my iphone during lunch break. I enjoy the information you provide here and can’t wait to take a look when I get home. I’m surprised at how fast your blog loaded on my cell phone .. I’m not even using WIFI, just 3G .. Anyways, awesome site!

  3. I think this is among the most vital info for me. And i am glad reading your article. But want to remark on few general things, The web site style is great, the articles is really excellent : D. Good job, cheers

发表回复

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

Back To Top

鄂ICP备17008157号-1