3v4l.org

run code in 300+ PHP versions simultaneously
<?php $members = array( array( 'num' => 2, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 2, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 3, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 3, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 3, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 3, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 3, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 5, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 9, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 9, 'rank' => 0, 'dense_rank' => 0, ), array( 'num' => 9, 'rank' => 0, 'dense_rank' => 0, ) ); $denseRank = 0; $gappedRank = 0; foreach ($members as &$row) { $denseRanks[$row['num']] ??= ++$denseRank; $row['dense_rank'] = $denseRanks[$row['num']]; ++$gappedRank; $gappedRanks[$row['num']] ??= $gappedRank; $row['rank'] = $gappedRanks[$row['num']]; // for better presentation: echo json_encode($row) . "\n"; } //var_export($members);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 4, Position 2 = 41
Branch analysis from position: 4
2 jumps found. (Code = 126) Position 1 = 5, Position 2 = 41
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/QadLk
function name:  (null)
number of ops:  43
compiled vars:  !0 = $members, !1 = $denseRank, !2 = $gappedRank, !3 = $row, !4 = $denseRanks, !5 = $gappedRanks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   61     1        ASSIGN                                                   !1, 0
   62     2        ASSIGN                                                   !2, 0
   63     3      > FE_RESET_RW                                      $9      !0, ->41
          4    > > FE_FETCH_RW                                              $9, !3, ->41
   64     5    >   FETCH_DIM_R                                      ~10     !3, 'num'
          6        COPY_TMP                                         ~11     ~10
          7        FETCH_DIM_IS                                     ~12     !4, ~10
          8        COALESCE                                         ~13     ~12
          9        PRE_INC                                          ~14     !1
         10        ASSIGN_DIM                                       ~15     !4, ~11
         11        OP_DATA                                                  ~14
         12        QM_ASSIGN                                        ~13     ~15
         13      > JMP                                                      ->15
         14*       FREE                                                     ~11
         15    >   FREE                                                     ~13
   65    16        FETCH_DIM_R                                      ~17     !3, 'num'
         17        FETCH_DIM_R                                      ~18     !4, ~17
         18        ASSIGN_DIM                                               !3, 'dense_rank'
         19        OP_DATA                                                  ~18
   67    20        PRE_INC                                                  !2
   68    21        FETCH_DIM_R                                      ~20     !3, 'num'
         22        COPY_TMP                                         ~21     ~20
         23        FETCH_DIM_IS                                     ~22     !5, ~20
         24        COALESCE                                         ~23     ~22
         25        ASSIGN_DIM                                       ~24     !5, ~21
         26        OP_DATA                                                  !2
         27        QM_ASSIGN                                        ~23     ~24
         28      > JMP                                                      ->30
         29*       FREE                                                     ~21
         30    >   FREE                                                     ~23
   69    31        FETCH_DIM_R                                      ~26     !3, 'num'
         32        FETCH_DIM_R                                      ~27     !5, ~26
         33        ASSIGN_DIM                                               !3, 'rank'
         34        OP_DATA                                                  ~27
   72    35        INIT_FCALL                                               'json_encode'
         36        SEND_VAR                                                 !3
         37        DO_ICALL                                         $28     
         38        CONCAT                                           ~29     $28, '%0A'
         39        ECHO                                                     ~29
   63    40      > JMP                                                      ->4
         41    >   FE_FREE                                                  $9
   74    42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.49 ms | 1013 KiB | 15 Q