3v4l.org

run code in 300+ PHP versions simultaneously
<?php function reindexWeeks($sourceWeeks, &$destWeeks, &$idxNew) { foreach($sourceWeeks as $sourceKey => $sourceValue) { if (is_array($sourceValue)) { $destWeeks[$idxNew] = array(); reindexWeeks($sourceValue, $destWeeks[$idxNew], $idxNew); } else { $destWeeks[$idxNew] = $sourceValue; $idxNew++; } } } $idxNew = 1; // starting index. $newWeeks = array(); // output array at the 'week' level $month = array ( 'weeks'=> array( 'w1'=> array( 'd1'=> 'day one', 'd2'=> 'day two', 'd3'=> array( 'H1' => 'hour one', 'H2' => 'hour two' ) ), 'w2'=> array( 'd1'=> 'day one', 'd2'=> 'day two' ) ) ); reindexWeeks($month['weeks'], $newWeeks, $idxNew); // re-index the array print_r($newWeeks);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Nd0JU
function name:  (null)
number of ops:  13
compiled vars:  !0 = $idxNew, !1 = $newWeeks, !2 = $month
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, 1
   18     1        ASSIGN                                                   !1, <array>
   20     2        ASSIGN                                                   !2, <array>
   37     3        INIT_FCALL                                               'reindexweeks'
          4        FETCH_DIM_R                                      ~6      !2, 'weeks'
          5        SEND_VAL                                                 ~6
          6        SEND_REF                                                 !1
          7        SEND_REF                                                 !0
          8        DO_FCALL                                      0          
   39     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function reindexweeks:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/Nd0JU
function name:  reindexWeeks
number of ops:  24
compiled vars:  !0 = $sourceWeeks, !1 = $destWeeks, !2 = $idxNew, !3 = $sourceValue, !4 = $sourceKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3      > FE_RESET_R                                       $5      !0, ->22
          4    > > FE_FETCH_R                                       ~6      $5, !3, ->22
          5    >   ASSIGN                                                   !4, ~6
    6     6        TYPE_CHECK                                  128          !3
          7      > JMPZ                                                     ~8, ->18
    7     8    >   ASSIGN_DIM                                               !1, !2
          9        OP_DATA                                                  <array>
    8    10        INIT_FCALL_BY_NAME                                       'reindexWeeks'
         11        SEND_VAR_EX                                              !3
         12        CHECK_FUNC_ARG                                           
         13        FETCH_DIM_FUNC_ARG                               $10     !1, !2
         14        SEND_FUNC_ARG                                            $10
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0          
         17      > JMP                                                      ->21
   11    18    >   ASSIGN_DIM                                               !1, !2
         19        OP_DATA                                                  !3
   12    20        PRE_INC                                                  !2
    5    21    > > JMP                                                      ->4
         22    >   FE_FREE                                                  $5
   15    23      > RETURN                                                   null

End of function reindexweeks

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.56 ms | 1403 KiB | 16 Q