3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class SomeClass { var $someProperty; function __construct($prop) { $this->someProperty = $prop; } function getSomeProperty() { return $this->someProperty; } function __toString() { return "" . $this->someProperty; } } $arr = array(); $someObject = new SomeClass(3); $arr[] = $someObject; $arr[] = $someObject; $someOtherObject = new SomeClass(4); $arr[] = $someOtherObject; $arr[] = $someOtherObject; print_r($arr); $arrFiltered = array_unique($arr); print_r($arrFiltered);
based on cV1aL
Output for 5.1.3 - 7.1.0
Array ( [0] => SomeClass Object ( [someProperty] => 3 ) [1] => SomeClass Object ( [someProperty] => 3 ) [2] => SomeClass Object ( [someProperty] => 4 ) [3] => SomeClass Object ( [someProperty] => 4 ) ) Array ( [0] => SomeClass Object ( [someProperty] => 3 ) [2] => SomeClass Object ( [someProperty] => 4 ) )
Output for 5.0.0 - 5.1.2
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in /in/7aZvB on line 5 Array ( [0] => SomeClass Object ( [someProperty] => 3 ) [1] => SomeClass Object ( [someProperty] => 3 ) [2] => SomeClass Object ( [someProperty] => 4 ) [3] => SomeClass Object ( [someProperty] => 4 ) ) Array ( [0] => SomeClass Object ( [someProperty] => 3 ) [2] => SomeClass Object ( [someProperty] => 4 ) )
Output for 4.3.0 - 4.4.9
Array ( [0] => someclass Object ( [someProperty] => ) [1] => someclass Object ( [someProperty] => ) [2] => someclass Object ( [someProperty] => ) [3] => someclass Object ( [someProperty] => ) ) Array ( [0] => someclass Object ( [someProperty] => ) )