3v4l.org

run code in 300+ PHP versions simultaneously
<?php class SortMadness { private $data; public function __construct($data) { $this->data = $data; } public function __toString() { //$data = array_map(function($item) { return $item; }, $this->data); $data = array_merge($this->data); sort($data); $rs = implode('-', $data); echo $rs."\n"; return $rs; } } // expected order is ['a','b'],['c','b','a'],['c','b'] $a = [ new SortMadness(['c','b']), new SortMadness(['c','b','a']), new SortMadness(['a','b']), ]; sort($a); print_r($a); usort($a, 'strcmp'); /* usort($a, function(ToStringMadness $itemA, ToStringMadness $itemB) { return strcmp((string)$itemA, (string)$itemB); }); */ print_r($a);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => a [1] => b ) ) [1] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b ) ) [2] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b [2] => a ) ) ) a-b b-c b-c a-b-c a-b a-b-c Array ( [0] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => a [1] => b ) ) [1] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b [2] => a ) ) [2] => SortMadness Object ( [data:SortMadness:private] => Array ( [0] => c [1] => b ) ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
53.56 ms | 404 KiB | 8 Q