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);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 37
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 37
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 14
filename:       /in/XFMm5
function name:  (null)
number of ops:  42
compiled vars:  !0 = $input, !1 = $result, !2 = $locked, !3 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, <array>
   14     2        ASSIGN                                                   !2, <array>
   15     3      > FE_RESET_R                                       $7      !0, ->14
          4    > > FE_FETCH_R                                               $7, !3, ->14
   16     5    >   FETCH_DIM_R                                      ~8      !3, 'lock'
          6        IS_SMALLER                                               0, ~8
          7      > JMPZ                                                     ~9, ->11
   17     8    >   ASSIGN_DIM                                               !2
          9        OP_DATA                                                  !3
   16    10      > JMP                                                      ->13
   19    11    >   ASSIGN_DIM                                               !1
         12        OP_DATA                                                  !3
   15    13    > > JMP                                                      ->4
         14    >   FE_FREE                                                  $7
   23    15        INIT_FCALL                                               'usort'
         16        SEND_REF                                                 !1
         17        DECLARE_LAMBDA_FUNCTION                          ~12     [0]
         18        SEND_VAL                                                 ~12
         19        DO_ICALL                                                 
   25    20        INIT_FCALL                                               'usort'
         21        SEND_REF                                                 !2
         22        DECLARE_LAMBDA_FUNCTION                          ~14     [1]
         23        SEND_VAL                                                 ~14
         24        DO_ICALL                                                 
   27    25      > FE_RESET_R                                       $16     !2, ->37
         26    > > FE_FETCH_R                                               $16, !3, ->37
   28    27    >   INIT_FCALL                                               'array_splice'
         28        SEND_REF                                                 !1
         29        FETCH_DIM_R                                      ~17     !3, 'lock'
         30        SUB                                              ~18     ~17, 1
         31        SEND_VAL                                                 ~18
         32        SEND_VAL                                                 0
         33        INIT_ARRAY                                       ~19     !3
         34        SEND_VAL                                                 ~19
         35        DO_ICALL                                                 
   27    36      > JMP                                                      ->26
         37    >   FE_FREE                                                  $16
   31    38        INIT_FCALL                                               'var_export'
         39        SEND_VAR                                                 !1
         40        DO_ICALL                                                 
         41      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XFMm5
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !0, 'score'
          3        INIT_ARRAY                                       ~3      ~2
          4        FETCH_DIM_R                                      ~4      !0, 'strtotime'
          5        ADD_ARRAY_ELEMENT                                ~3      ~4
          6        FETCH_DIM_R                                      ~5      !1, 'score'
          7        INIT_ARRAY                                       ~6      ~5
          8        FETCH_DIM_R                                      ~7      !1, 'strtotime'
          9        ADD_ARRAY_ELEMENT                                ~6      ~7
         10        SPACESHIP                                        ~8      ~3, ~6
         11      > RETURN                                                   ~8
         12*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XFMm5
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !0, 'lock'
          3        FETCH_DIM_R                                      ~3      !1, 'lock'
          4        SPACESHIP                                        ~4      ~2, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.36 ms | 1017 KiB | 16 Q