- print_r: documentation ( source)
- array_filter: documentation ( source)
- in_array: documentation ( source)
<?php
class MyClass {
public $prop;
}
$foo = new MyClass();
$foo->prop = 'test1';
$bar = $foo;
$bam = new MyClass();
$bam->prop = 'test2';
$t = new MyClass();
$t->prop = 'test1';
$test = array($foo, $bar, $bam, $t);
function filter_them( $obj ) {
static $new_arr;
if ( ! in_array( $new_arr, $obj->prop ) ){
$new_arr[] = $obj->prop;
return true;
}
}
print_r(array_filter($test, 'filter_them'));