3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class AHeap extends SplHeap { public function __construct($i) { foreach ($i as $obj) { $this->insert($obj); } } } class KeySort extends AHeap { protected function compare($val1, $val2) { if ($val1->key == $val2->key) { if ($val1->value == $val2->value) { return 0; } if ($val1->value > $val2->value){ return -1; } else { return 1; } } if ($val1->key > $val2->key){ return -1; } else { return 1; } } } $array = array( (object) array('key' => 0, 'value' => 'z'), (object) array('key' => 0, 'value' => 'a'), (object) array('key' => 2, 'value' => 'y'), (object) array('key' => 3, 'value' => 'b'), ); $heap = new KeySort($array); foreach ($heap2 as $val) { echo $val->key . ' - ' . $val->value . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of KeySort::compare($val1, $val2) should either be compatible with SplHeap::compare(mixed $value1, mixed $value2): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/B6uMS on line 15 Warning: Undefined variable $heap2 in /in/B6uMS on line 48 Warning: foreach() argument must be of type array|object, null given in /in/B6uMS on line 48

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:
36.18 ms | 402 KiB | 8 Q