3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $deps = [ ['for' => '$T3', 'deps' => ['$T2'] ], ['for' => '$T1', 'deps' => [] ], ['for' => '$T2', 'deps' => ['$T1'] ] ]; uasort($deps, function($a, $b){ in_array($a['for'], $b) ? -1 : 1; }); var_dump($deps);
based on DNfgU
Output for 7.0.0 - 7.2.0
array(3) { [0]=> array(2) { ["for"]=> string(3) "$T3" ["deps"]=> array(1) { [0]=> string(3) "$T2" } } [1]=> array(2) { ["for"]=> string(3) "$T1" ["deps"]=> array(0) { } } [2]=> array(2) { ["for"]=> string(3) "$T2" ["deps"]=> array(1) { [0]=> string(3) "$T1" } } }
Output for 5.4.10 - 5.6.28
array(3) { [2]=> array(2) { ["for"]=> string(3) "$T2" ["deps"]=> array(1) { [0]=> string(3) "$T1" } } [1]=> array(2) { ["for"]=> string(3) "$T1" ["deps"]=> array(0) { } } [0]=> array(2) { ["for"]=> string(3) "$T3" ["deps"]=> array(1) { [0]=> string(3) "$T2" } } }
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/4NpjA on line 3
Process exited with code 255.