3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ ['name' => 'Hank'], ['name' => 'Beavis'], ['name' => 'Butthead'], ['name' => 'Cornholio', 'caffine_powered' => true], ]; $sorter = function($a, $b){ if( key_exists('caffine_powered', $a) && key_exists('caffine_powered', $b) ) { // both exist return $a['name'] <=> $b['name']; } else if( ! (key_exists('caffine_powered', $a) || key_exists('caffine_powered', $b)) ) { // neither exist return $a['name'] <=> $b['name']; } else if( key_exists('caffine_powered', $a) ) { // just a return -1; } else { // just b return 1; } }; usort($items, $sorter); var_dump($items);
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [0]=> array(2) { ["name"]=> string(9) "Cornholio" ["caffine_powered"]=> bool(true) } [1]=> array(1) { ["name"]=> string(6) "Beavis" } [2]=> array(1) { ["name"]=> string(8) "Butthead" } [3]=> array(1) { ["name"]=> string(4) "Hank" } }

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