3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mda[0][5][10] = "string value"; $mda[1][15][20] = "string value"; $mda[2][25][30] = "string value"; echo "ORIGINAL ARRAY\r\n\r\n"; var_dump($mda); echo "\r\nWONT WORK:\r\n\r\n"; var_dump(array_values($mda)); function fix_keys($array) { foreach ($array as $k => $val) { if (is_array($val)) $array[$k] = fix_keys($val); //recurse } return array_values($array); } echo "\r\nWILL WORK:\r\n\r\n"; var_dump(fix_keys($mda));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vGmmJ
function name:  (null)
number of ops:  31
compiled vars:  !0 = $mda
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_DIM_W                                      $1      !0, 0
          1        FETCH_DIM_W                                      $2      $1, 5
          2        ASSIGN_DIM                                               $2, 10
          3        OP_DATA                                                  'string+value'
    4     4        FETCH_DIM_W                                      $4      !0, 1
          5        FETCH_DIM_W                                      $5      $4, 15
          6        ASSIGN_DIM                                               $5, 20
          7        OP_DATA                                                  'string+value'
    5     8        FETCH_DIM_W                                      $7      !0, 2
          9        FETCH_DIM_W                                      $8      $7, 25
         10        ASSIGN_DIM                                               $8, 30
         11        OP_DATA                                                  'string+value'
    7    12        ECHO                                                     'ORIGINAL+ARRAY%0D%0A%0D%0A'
    8    13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
   10    16        ECHO                                                     '%0D%0AWONT+WORK%3A%0D%0A%0D%0A'
   11    17        INIT_FCALL                                               'var_dump'
         18        INIT_FCALL                                               'array_values'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $11     
         21        SEND_VAR                                                 $11
         22        DO_ICALL                                                 
   22    23        ECHO                                                     '%0D%0AWILL+WORK%3A%0D%0A%0D%0A'
   23    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'fix_keys'
         26        SEND_VAR                                                 !0
         27        DO_FCALL                                      0  $13     
         28        SEND_VAR                                                 $13
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function fix_keys:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/vGmmJ
function name:  fix_keys
number of ops:  18
compiled vars:  !0 = $array, !1 = $val, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->12
          3    >   ASSIGN                                                   !2, ~4
   16     4        TYPE_CHECK                                  128          !1
          5      > JMPZ                                                     ~6, ->11
   17     6    >   INIT_FCALL_BY_NAME                                       'fix_keys'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $8      
          9        ASSIGN_DIM                                               !0, !2
         10        OP_DATA                                                  $8
   15    11    > > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   19    13        INIT_FCALL                                               'array_values'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $9      
         16      > RETURN                                                   $9
   20    17*     > RETURN                                                   null

End of function fix_keys

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.58 ms | 1403 KiB | 18 Q