Say I have an array of objects all have a public member called id, I would like to remove all "duplicates":

This is my attempt:

```
<?php

$a = new stdClass;
$a->id = 1;

$b = new stdClass;
$b->id = 2;

$c = new stdClass;
$c->id = 3;

$d = new stdClass;
$d->id = 1;

$objects = array($a, $b, $c, $d);

var_dump( (array) $objects);

echo '<hr>';

$temp = $objects;

foreach ($objects as &$object) {

    foreach ($temp as $object2) {
        if ($object2->id === $object->id) {
            unset($object);
            continue;
        }
    }

}

echo '<hr>';

var_dump($objects);

?>

Notice: Undefined variable: object in C:\Apache24\htdocs\objects.php on line 25

Notice: Trying to get property of non-object in C:\Apache24\htdocs\objects.php on line 25

```

What am I missing here? Is there any in-built function to accomplish this instead maybe?