Voting

: max(one, one)?
(Example: nine)

The Note You're Voting On

sashasimkin at gmail dot com
13 years ago
My object unique function:

<?php
function object_unique( $obj ){
$objArray = (array) $obj;

$objArray = array_intersect_assoc( array_unique( $objArray ), $objArray );

foreach(
$obj as $n => $f ) {
if( !
array_key_exists( $n, $objArray ) ) unset( $obj->$n );
}

return
$obj;
}
?>

And these code:

<?php
class Test{
public
$pr0 = 'string';
public
$pr1 = 'string1';
public
$pr2 = 'string';
public
$pr3 = 'string2';
}

$obj = new Test;

var_dump( object_unique( $obj ) );
?>

returns:
object(Test)[1]
public 'pr0' => string 'string' (length=6)
public 'pr1' => string 'string1' (length=7)
public 'pr3' => string 'string2' (length=7)

<< Back to user notes page

To Top