3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testArray = ['a' => ['b' => 'l'], 'c' => 'm', 'd' => ['n' => 'o']]; $actionArray = ['setType' => ['b' => 'int']]; function toUpperRecursive($arr, $actionArray) { foreach ($arr as $key => $val) { if (is_array($val)) { // $newKey = strtoupper($key); $arr[$key] = toUpperRecursive($val, $actionArray); // unset($arr[$key]); } elseif (is_string($val)) { echo $key . "\n"; echo $val . "\n"; foreach($actionArray as $actionType => $keyParamArray) { echo $actionType . "\n"; // echo $foo . "\n"; foreach ($keyParamArray as $actionKey => $actionParam) { if($key === $actionKey) { switch ($actionType) { case 'setType': echo $actionParam . "\n"; $arr[$key] = $val . ' + 1111'; break; } } } } } } return $arr; } // echo "before:\n"; // var_export($testArray); // echo "after:\n"; // var_export(toUpperRecursive($testArray)); var_export(toUpperRecursive($testArray, $actionArray));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/neTHt
function name:  (null)
number of ops:  10
compiled vars:  !0 = $testArray, !1 = $actionArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
   42     2        INIT_FCALL                                               'var_export'
          3        INIT_FCALL                                               'toupperrecursive'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function toupperrecursive:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 44
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 44
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 43
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 42
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 42
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 40
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 40
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 39
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 39
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 40
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 42
Branch analysis from position: 43
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/neTHt
function name:  toUpperRecursive
number of ops:  47
compiled vars:  !0 = $arr, !1 = $actionArray, !2 = $val, !3 = $key, !4 = $keyParamArray, !5 = $actionType, !6 = $actionParam, !7 = $actionKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2      > FE_RESET_R                                       $8      !0, ->44
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->44
          4    >   ASSIGN                                                   !3, ~9
   10     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~11, ->14
   12     7    >   INIT_FCALL_BY_NAME                                       'toUpperRecursive'
          8        SEND_VAR_EX                                              !2
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $13     
         11        ASSIGN_DIM                                               !0, !3
         12        OP_DATA                                                  $13
         13      > JMP                                                      ->43
   15    14    >   TYPE_CHECK                                   64          !2
         15      > JMPZ                                                     ~14, ->43
   16    16    >   CONCAT                                           ~15     !3, '%0A'
         17        ECHO                                                     ~15
   17    18        CONCAT                                           ~16     !2, '%0A'
         19        ECHO                                                     ~16
   18    20      > FE_RESET_R                                       $17     !1, ->42
         21    > > FE_FETCH_R                                       ~18     $17, !4, ->42
         22    >   ASSIGN                                                   !5, ~18
   19    23        CONCAT                                           ~20     !5, '%0A'
         24        ECHO                                                     ~20
   21    25      > FE_RESET_R                                       $21     !4, ->40
         26    > > FE_FETCH_R                                       ~22     $21, !6, ->40
         27    >   ASSIGN                                                   !7, ~22
   22    28        IS_IDENTICAL                                             !3, !7
         29      > JMPZ                                                     ~24, ->39
   24    30    >   IS_EQUAL                                                 !5, 'setType'
         31      > JMPNZ                                                    ~25, ->33
         32    > > JMP                                                      ->39
   25    33    >   CONCAT                                           ~26     !6, '%0A'
         34        ECHO                                                     ~26
   26    35        CONCAT                                           ~28     !2, '+%2B+1111'
         36        ASSIGN_DIM                                               !0, !3
         37        OP_DATA                                                  ~28
   27    38      > JMP                                                      ->39
   21    39    > > JMP                                                      ->26
         40    >   FE_FREE                                                  $21
   18    41      > JMP                                                      ->21
         42    >   FE_FREE                                                  $17
    8    43    > > JMP                                                      ->3
         44    >   FE_FREE                                                  $8
   35    45      > RETURN                                                   !0
   36    46*     > RETURN                                                   null

End of function toupperrecursive

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.91 ms | 1403 KiB | 16 Q