How to get unique value in multidimensional array

前端 未结 8 1171
盖世英雄少女心
盖世英雄少女心 2020-12-01 03:34

I have done a lot of looking around on the overflow, and on google, but none of the results works for my specific case.

I have a placeholder array called $holder, va

相关标签:
8条回答
  • 2020-12-01 04:24

    Just iterate over it and apply an array_unique on the result:

    foreach($holder as $yourValues){
        $pids[] = $yourValues['pid'];
    }
    $yourUniquePids = array_unique($pids);
    
    0 讨论(0)
  • 2020-12-01 04:28

    In php >= 5.5 you can use array_column:

    array_unique(array_column($holder, 'pid'));
    
    0 讨论(0)
提交回复
热议问题