3v4l.org

run code in 300+ PHP versions simultaneously
<?php $multidimArray = [ 'a' => [ 'boolean' => true, 'natString' => 'text10', 'object' => (object)['prop' => 2], 'float' => -.5, 'mixed' => [] ], 'b' => [ 'boolean' => true, 'natString' => 'text12', 'object' => (object)['prop' => 4], 'float' => 0, 'mixed' => null ], 'c' => [ 'boolean' => false, 'natString' => 'text100', 'object' => (object)['prop' => 9], 'float' => -.5, 'mixed' => false ], 'd' => [ 'boolean' => true, 'natString' => 'text1', 'object' => (object)['prop' => 9], 'float' => -5, 'mixed' => "\0" ], 'e' => [ 'boolean' => false, 'natString' => 'text2', 'object' => (object)['prop' => 2], 'float' => .5, 'mixed' => '' ] ]; //Sorting logic: boolean DESC (false = 0, true = 1, so trues before falses), float ASC uasort($multidimArray, function($a, $b) { return [$b['boolean'], $a['float']] <=> [$a['boolean'], $b['float']]; }); var_export($multidimArray); echo "\n---\n"; //Sorting logic: mixed ASC, object ASC, boolean ASC uasort($multidimArray, function($a, $b) { return [$a['mixed'], $a['object']->prop, $a['boolean']] <=> [$b['mixed'], $b['object']->prop, $b['boolean']]; }); var_export($multidimArray); echo "\n---\n"; //Sorting logic: property count of object ASC, iterability of mixed DESC, natString length ASC, natString ASC uasort($multidimArray, function($a, $b) { return [count(get_object_vars($a['object'])), is_iterable($a['mixed']), strlen($a['natString']), $a['natString']] <=> [count(get_object_vars($b['object'])), is_iterable($b['mixed']), strlen($b['natString']), $b['natString']]; }); var_export($multidimArray); echo "\n---\n";
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'd' => array ( 'boolean' => true, 'natString' => 'text1', 'object' => (object) array( 'prop' => 9, ), 'float' => -5, 'mixed' => '' . "\0" . '', ), 'a' => array ( 'boolean' => true, 'natString' => 'text10', 'object' => (object) array( 'prop' => 2, ), 'float' => -0.5, 'mixed' => array ( ), ), 'b' => array ( 'boolean' => true, 'natString' => 'text12', 'object' => (object) array( 'prop' => 4, ), 'float' => 0, 'mixed' => NULL, ), 'c' => array ( 'boolean' => false, 'natString' => 'text100', 'object' => (object) array( 'prop' => 9, ), 'float' => -0.5, 'mixed' => false, ), 'e' => array ( 'boolean' => false, 'natString' => 'text2', 'object' => (object) array( 'prop' => 2, ), 'float' => 0.5, 'mixed' => '', ), ) --- array ( 'e' => array ( 'boolean' => false, 'natString' => 'text2', 'object' => (object) array( 'prop' => 2, ), 'float' => 0.5, 'mixed' => '', ), 'd' => array ( 'boolean' => true, 'natString' => 'text1', 'object' => (object) array( 'prop' => 9, ), 'float' => -5, 'mixed' => '' . "\0" . '', ), 'a' => array ( 'boolean' => true, 'natString' => 'text10', 'object' => (object) array( 'prop' => 2, ), 'float' => -0.5, 'mixed' => array ( ), ), 'b' => array ( 'boolean' => true, 'natString' => 'text12', 'object' => (object) array( 'prop' => 4, ), 'float' => 0, 'mixed' => NULL, ), 'c' => array ( 'boolean' => false, 'natString' => 'text100', 'object' => (object) array( 'prop' => 9, ), 'float' => -0.5, 'mixed' => false, ), ) --- array ( 'd' => array ( 'boolean' => true, 'natString' => 'text1', 'object' => (object) array( 'prop' => 9, ), 'float' => -5, 'mixed' => '' . "\0" . '', ), 'e' => array ( 'boolean' => false, 'natString' => 'text2', 'object' => (object) array( 'prop' => 2, ), 'float' => 0.5, 'mixed' => '', ), 'b' => array ( 'boolean' => true, 'natString' => 'text12', 'object' => (object) array( 'prop' => 4, ), 'float' => 0, 'mixed' => NULL, ), 'c' => array ( 'boolean' => false, 'natString' => 'text100', 'object' => (object) array( 'prop' => 9, ), 'float' => -0.5, 'mixed' => false, ), 'a' => array ( 'boolean' => true, 'natString' => 'text10', 'object' => (object) array( 'prop' => 2, ), 'float' => -0.5, 'mixed' => array ( ), ), ) ---

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:
40.84 ms | 416 KiB | 5 Q