3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class SortMadness { private $data; public function __construct($data) { $this->data = $data; } public function __toString() { $data = array_merge($this->data); sort($data); $rs = implode('-', $data); echo $rs."\n"; return $rs; } } // expected result is ['c','b'],['c','b','a'] $a = array( new SortMadness(array('c','b')), new SortMadness(array('c','b','a')), new SortMadness(array('a','b','c')), ); $rs = array_unique($a, SORT_STRING); print_r($rs); /* usort($a, 'strcmp'); print_r($a); */
based on uck5f
Output for 7.2.0
b-c a-b-c a-b-c Array ( [0] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b ) ) [1] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b [2] => a ) ) )
Output for 7.0.0 - 7.1.10
b-c a-b-c a-b-c a-b-c a-b-c a-b-c a-b-c b-c Array ( [0] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b ) ) [1] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b [2] => a ) ) )
Output for 5.3.19 - 5.6.28
a-b-c b-c Array ( [0] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b ) ) [1] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b [2] => a ) ) [2] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => a [1] => b [2] => c ) ) )