fork download
  1. <?php
  2.  
  3. $array = array(
  4. 'item-1' => array(
  5. 'a' => 'Повторяющееся значение 1',
  6. 'b' => 'xx1',
  7. 'c' => 'xx2'
  8. ),
  9. 'item-2' => array(
  10. 'a' => 'Повторяющееся значение 1',
  11. 'b' => 'xx3',
  12. 'c' => 'xx4'
  13. ),
  14. 'item-3' => array(
  15. 'a' => 'Повторяющееся значение 2',
  16. 'b' => 'xx5',
  17. 'c' => 'xx6'
  18. ),
  19. 'item-4' => array(
  20. 'a' => 'Повторяющееся значение 2',
  21. 'b' => 'xx7',
  22. 'c' => 'xx8'
  23. )
  24. );
  25.  
  26. foreach (array_reverse($array, true) as $id => $item) {
  27. if (in_array($item['a'], array_column(array_slice($array, $id + 1), 'a'))) {
  28. unset($array[$id]);
  29. }
  30. }
  31.  
  32. var_dump($array);
Success #stdin #stdout #stderr 0.03s 24236KB
stdin
Standard input is empty
stdout
array(1) {
  ["item-1"]=>
  array(3) {
    ["a"]=>
    string(45) "Повторяющееся значение 1"
    ["b"]=>
    string(3) "xx1"
    ["c"]=>
    string(3) "xx2"
  }
}
stderr
PHP Warning:  A non-numeric value encountered in /home/4pWbsT/prog.php on line 27
PHP Warning:  A non-numeric value encountered in /home/4pWbsT/prog.php on line 27
PHP Warning:  A non-numeric value encountered in /home/4pWbsT/prog.php on line 27
PHP Warning:  A non-numeric value encountered in /home/4pWbsT/prog.php on line 27