[ create a new paste ] login | about

Link: http://codepad.org/8YQwU4xA    [ raw code | output | fork ]

PHP, pasted on Mar 19:
<?php

$arrNames = array(
  array('first'=>'John', 'last'=>'Smith', id=>'1'),
  array('first'=>'John', 'last'=>'Smith', id=>'2'),
  array('first'=>'John', 'last'=>'Smith', id=>'3')
);

$arrFound = array();

foreach ($arrNames as $k => $arrPerson) {
  $arrPersonNoId = array(
    'first' => $arrPerson['first'],
    'last' => $arrPerson['last']
  );
  if (in_array($arrPersonNoId, $arrFound)) {
    unset($arrNames[$k]);
  } else {
    $arrFound[] = $arrPersonNoId;
  }
}

print_r($arrNames);


Output:
1
2
3
4
5
6
7
8
9
10
Array
(
    [0] => Array
        (
            [first] => John
            [last] => Smith
            [id] => 1
        )

)


Create a new paste based on this one


Comments: