3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['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], ]; $maxIndex = count($array) - 1; for ($a = 0; $a < $maxIndex; ++$a) { if ($array[$a]['lock'] !== 0) { continue; // cannot move locked row } for ($b = 0; $b < $maxIndex; ++$b) { if ($array[$b]['lock'] !== 0) { continue; // cannot move locked row } // find next movable row for ($c = $b + 1; $c <= $maxIndex; ++$c) { if ($array[$c]['lock'] === 0) { break; // $c is index of non-locked row } } if ($c > $maxIndex) { break; // no more movable rows } // sort movable rows if ( $array[$b]['score'] > $array[$c]['score'] || ($array[$b]['score'] === $array[$c]['score'] && $array[$b]['strtotime'] > $array[$c]['strtotime']) ) { [$array[$b], $array[$c]] = [$array[$c], $array[$b]]; } } } var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
2 jumps found. (Code = 44) Position 1 = 69, Position 2 = 6
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 69, Position 2 = 6
Branch analysis from position: 69
Branch analysis from position: 6
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 13
Branch analysis from position: 66
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 13
Branch analysis from position: 66
Branch analysis from position: 13
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 21
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
Branch analysis from position: 32
2 jumps found. (Code = 47) Position 1 = 38, Position 2 = 51
Branch analysis from position: 38
2 jumps found. (Code = 46) Position 1 = 44, Position 2 = 50
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 63
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 66, Position 2 = 13
Branch analysis from position: 66
Branch analysis from position: 13
Branch analysis from position: 63
Branch analysis from position: 50
Branch analysis from position: 51
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 21
Branch analysis from position: 29
Branch analysis from position: 21
filename:       /in/YndB8
function name:  (null)
number of ops:  73
compiled vars:  !0 = $array, !1 = $maxIndex, !2 = $a, !3 = $b, !4 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        COUNT                                            ~6      !0
          2        SUB                                              ~7      ~6, 1
          3        ASSIGN                                                   !1, ~7
   14     4        ASSIGN                                                   !2, 0
          5      > JMP                                                      ->67
   15     6    >   FETCH_DIM_R                                      ~10     !0, !2
          7        FETCH_DIM_R                                      ~11     ~10, 'lock'
          8        IS_NOT_IDENTICAL                                         ~11, 0
          9      > JMPZ                                                     ~12, ->11
   16    10    > > JMP                                                      ->66
   18    11    >   ASSIGN                                                   !3, 0
         12      > JMP                                                      ->64
   19    13    >   FETCH_DIM_R                                      ~14     !0, !3
         14        FETCH_DIM_R                                      ~15     ~14, 'lock'
         15        IS_NOT_IDENTICAL                                         ~15, 0
         16      > JMPZ                                                     ~16, ->18
   20    17    > > JMP                                                      ->63
   23    18    >   ADD                                              ~17     !3, 1
         19        ASSIGN                                                   !4, ~17
         20      > JMP                                                      ->27
   24    21    >   FETCH_DIM_R                                      ~19     !0, !4
         22        FETCH_DIM_R                                      ~20     ~19, 'lock'
         23        IS_IDENTICAL                                             ~20, 0
         24      > JMPZ                                                     ~21, ->26
   25    25    > > JMP                                                      ->29
   23    26    >   PRE_INC                                                  !4
         27    >   IS_SMALLER_OR_EQUAL                                      !4, !1
         28      > JMPNZ                                                    ~23, ->21
   28    29    >   IS_SMALLER                                               !1, !4
         30      > JMPZ                                                     ~24, ->32
   29    31    > > JMP                                                      ->66
   33    32    >   FETCH_DIM_R                                      ~25     !0, !3
         33        FETCH_DIM_R                                      ~26     ~25, 'score'
         34        FETCH_DIM_R                                      ~27     !0, !4
         35        FETCH_DIM_R                                      ~28     ~27, 'score'
         36        IS_SMALLER                                       ~29     ~28, ~26
         37      > JMPNZ_EX                                         ~29     ~29, ->51
   34    38    >   FETCH_DIM_R                                      ~30     !0, !3
         39        FETCH_DIM_R                                      ~31     ~30, 'score'
         40        FETCH_DIM_R                                      ~32     !0, !4
         41        FETCH_DIM_R                                      ~33     ~32, 'score'
         42        IS_IDENTICAL                                     ~34     ~31, ~33
         43      > JMPZ_EX                                          ~34     ~34, ->50
   35    44    >   FETCH_DIM_R                                      ~35     !0, !3
         45        FETCH_DIM_R                                      ~36     ~35, 'strtotime'
         46        FETCH_DIM_R                                      ~37     !0, !4
         47        FETCH_DIM_R                                      ~38     ~37, 'strtotime'
         48        IS_SMALLER                                       ~39     ~38, ~36
         49        BOOL                                             ~34     ~39
         50    >   BOOL                                             ~29     ~34
         51    > > JMPZ                                                     ~29, ->63
   37    52    >   FETCH_DIM_R                                      ~40     !0, !4
         53        INIT_ARRAY                                       ~41     ~40
         54        FETCH_DIM_R                                      ~42     !0, !3
         55        ADD_ARRAY_ELEMENT                                ~41     ~42
         56        FETCH_LIST_R                                     $43     ~41, 0
         57        ASSIGN_DIM                                               !0, !3
         58        OP_DATA                                                  $43
         59        FETCH_LIST_R                                     $45     ~41, 1
         60        ASSIGN_DIM                                               !0, !4
         61        OP_DATA                                                  $45
         62        FREE                                                     ~41
   18    63    >   PRE_INC                                                  !3
         64    >   IS_SMALLER                                               !3, !1
         65      > JMPNZ                                                    ~48, ->13
   14    66    >   PRE_INC                                                  !2
         67    >   IS_SMALLER                                               !2, !1
         68      > JMPNZ                                                    ~50, ->6
   41    69    >   INIT_FCALL                                               'var_export'
         70        SEND_VAR                                                 !0
         71        DO_ICALL                                                 
         72      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.09 ms | 1009 KiB | 14 Q