3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ [ "points" => 10, "details" => ["name" => "Team A", "rank" => ""] ], [ "points" => 10, "details" => ["name" => "Team B", "rank" => ""] ], [ "points" => 8, "details" => ["name" => "Team C", "rank" => ""] ], [ "points" => 6, "details" => ["name" => "Team D", "rank" => ""] ], ]; $denseRank = 0; foreach ($array as ['points'=> $points, 'details' => ['rank' => &$rank]]) { $denseRanks[$points] ??= ++$denseRank; $rank = $denseRanks[$points]; } var_export($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/2AuBR
function name:  (null)
number of ops:  28
compiled vars:  !0 = $array, !1 = $denseRank, !2 = $points, !3 = $rank, !4 = $denseRanks
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   22     1        ASSIGN                                                       !1, 0
   23     2      > FE_RESET_RW                                          $7      !0, ->23
          3    > > FE_FETCH_RW                                                  $7, $8, ->23
          4    >   FETCH_LIST_R                                         $9      $8, 'points'
          5        ASSIGN                                                       !2, $9
          6        FETCH_LIST_W                                         $11     $8, 'details'
          7        MAKE_REF                                             $12     $11
          8        FETCH_LIST_W                                         $13     $12, 'rank'
          9        MAKE_REF                                             $14     $13
         10        ASSIGN_REF                                                   !3, $14
         11        FREE                                                         $12
         12        FREE                                                         $8
   24    13        FETCH_DIM_IS                                         ~16     !4, !2
         14        COALESCE                                             ~17     ~16
         15        PRE_INC                                              ~18     !1
         16        ASSIGN_DIM                                           ~19     !4, !2
         17        OP_DATA                                                      ~18
         18        QM_ASSIGN                                            ~17     ~19
         19        FREE                                                         ~17
   25    20        FETCH_DIM_R                                          ~20     !4, !2
         21        ASSIGN                                                       !3, ~20
   23    22      > JMP                                                          ->3
         23    >   FE_FREE                                                      $7
   27    24        INIT_FCALL                                                   'var_export'
         25        SEND_VAR                                                     !0
         26        DO_ICALL                                                     
         27      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
142.6 ms | 1848 KiB | 14 Q