fork(1) download
  1. <?php
  2.  
  3. $people[0]['age'] = 17;
  4. $people[0]['name'] = "鈴木";
  5. $people[0]['sex'] = "男性";
  6. $people[1]['age'] = 23;
  7. $people[1]['name'] = "佐藤";
  8. $people[1]['sex'] = "女性";
  9. $people[2]['age'] = 58;
  10. $people[2]['name'] = "鈴木";
  11. $people[2]['sex'] = "女性";
  12.  
  13. $people = array_filter(
  14. $people,
  15. function ($person) {
  16. static $names;
  17. $ret = !isset($names[$person['name']]);
  18. $names[$person['name']] = true;
  19. return $ret;
  20. }
  21. );
  22.  
  23. print_r($people);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [age] => 17
            [name] => 鈴木
            [sex] => 男性
        )

    [1] => Array
        (
            [age] => 23
            [name] => 佐藤
            [sex] => 女性
        )

)