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; $arrFiltered = array_unique($arr); print_r($arrFiltered);
based on Mde7t
Output for 5.1.3 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
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/cV1aL on line 5 Array ( [0] => SomeClass Object ( [someProperty] => 3 ) [2] => SomeClass Object ( [someProperty] => 4 ) )
Output for 4.3.0 - 4.4.9
Array ( [0] => someclass Object ( [someProperty] => ) )