3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ ['id' => 7867867, 'lock' => 0, 'score' => 322, 'strtotime' => 16614713], ['id' => 7867867, 'lock' => 0, 'score' => 444, 'strtotime' => 16614613], ['id' => 7867867, 'lock' => 3, 'score' => 0, 'strtotime' => 16613713], ['id' => 7867867, 'lock' => 0, 'score' => 11, 'strtotime' => 16612713], ['id' => 7867867, 'lock' => 5, 'score' => 0, 'strtotime' => 16614413], ['id' => 7867867, 'lock' => 0, 'score' => 42, 'strtotime' => 16614113], ['id' => 7867867, 'lock' => 0, 'score' => 22, 'strtotime' => 16614013], ]; $result = []; $locked = []; foreach ($input as $item) { if ($item['lock'] > 0) { $locked[] = $item; } else { $result[] = $item; } } usort($result, fn($a, $b) => [$a['score'], $a['strtotime']] <=> [$b['score'], $b['strtotime']]); usort($locked, fn($a, $b) => $a['lock'] <=> $b['lock']); foreach ($locked as $item) { array_splice($result, $item['lock'] - 1, 0, [$item]); } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'id' => 7867867, 'lock' => 0, 'score' => 11, 'strtotime' => 16612713, ), 1 => array ( 'id' => 7867867, 'lock' => 0, 'score' => 22, 'strtotime' => 16614013, ), 2 => array ( 'id' => 7867867, 'lock' => 3, 'score' => 0, 'strtotime' => 16613713, ), 3 => array ( 'id' => 7867867, 'lock' => 0, 'score' => 42, 'strtotime' => 16614113, ), 4 => array ( 'id' => 7867867, 'lock' => 5, 'score' => 0, 'strtotime' => 16614413, ), 5 => array ( 'id' => 7867867, 'lock' => 0, 'score' => 322, 'strtotime' => 16614713, ), 6 => array ( 'id' => 7867867, 'lock' => 0, 'score' => 444, 'strtotime' => 16614613, ), )

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:
140.89 ms | 407 KiB | 5 Q