3v4l.org

run code in 300+ PHP versions simultaneously
<?php function reKey($oldArray, $value, $newArray=Array()) { if (count($oldArray)) { $currentValue = current($oldArray); unset($oldArray[key($oldArray)]); $newArray[$currentValue] = Array(); print_r($newArray); $newArray = reKey($oldArray, $value, $newArray[$currentValue]); } else{ $newArray[key($newArray)] = $value; } return $newArray; } $array = Array( 0 => "this", 1 => "that", 2 => "those", 3 => "they", ); $newArray = reKey($array, "asdadsad", Array()); print_r($newArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lLHp2
function name:  (null)
number of ops:  11
compiled vars:  !0 = $array, !1 = $newArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   24     1        INIT_FCALL                                               'rekey'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'asdadsad'
          4        SEND_VAL                                                 <array>
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !1, $3
   26     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function rekey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 27
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lLHp2
function name:  reKey
number of ops:  34
compiled vars:  !0 = $oldArray, !1 = $value, !2 = $newArray, !3 = $currentValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
    4     3        COUNT                                            ~4      !0
          4      > JMPZ                                                     ~4, ->27
    5     5    >   INIT_FCALL                                               'current'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        ASSIGN                                                   !3, $5
    6     9        INIT_FCALL                                               'key'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $7      
         12        UNSET_DIM                                                !0, $7
    7    13        ASSIGN_DIM                                               !2, !3
         14        OP_DATA                                                  <array>
    8    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
    9    18        INIT_FCALL_BY_NAME                                       'reKey'
         19        SEND_VAR_EX                                              !0
         20        SEND_VAR_EX                                              !1
         21        CHECK_FUNC_ARG                                           
         22        FETCH_DIM_FUNC_ARG                               $10     !2, !3
         23        SEND_FUNC_ARG                                            $10
         24        DO_FCALL                                      0  $11     
         25        ASSIGN                                                   !2, $11
         26      > JMP                                                      ->32
   11    27    >   INIT_FCALL                                               'key'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $13     
         30        ASSIGN_DIM                                               !2, $13
         31        OP_DATA                                                  !1
   14    32    > > RETURN                                                   !2
   15    33*     > RETURN                                                   null

End of function rekey

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
208.86 ms | 1403 KiB | 20 Q