Array
(
    [0] => Array
        (
            [file] => /var/websites/example.com/assets/images/200px/1419050406e6648e1c766551a0ffc91380fd6ff3406002011-10-233750.jpg
            [md5] => 42479bee7a304d2318250de2ef1962a9
            [url] => http://example.com/assets/images/200px/1419050406e6648e1c766551a0ffc91380fd6ff3406002011-10-233750.jpg
        )
    [1] => Array
        (
            [file] => /var/websites/example.com/assets/images/200px/21277792606e6648e1c766551a0ffc91380fd6ff3406002011-10-233750.jpg
            [md5] => 42479bee7a304d2318250de2ef1962a9
            [url] => http://example.com/assets/images/200px/21277792606e6648e1c766551a0ffc91380fd6ff3406002011-10-233750.jpg
        )
)
How can I remove md5 key duplicates from above array?
As array_unique operates on flat arrays, you can not use it directly. But you can first map all 'md5' values to a flat array, unique it and then get the elements with array_intersect_key:
$allMd5s = array_map(function($v) {return $v['md5'];}, $array);
$uniqueMd5s = array_unique($md5);
$result = array_intersect_key($arr, $uniqueMd5s);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With