3v4l.org

run code in 300+ PHP versions simultaneously
<?php $controlValue = [ 'item1' => 'val1', 'item2' => 'val2', 'item3' => [ 'item4' => 'val4', 'item5' => 'val5', ], ]; $encryptedFields = [ 'item2', 'item3.item5', ]; foreach ($encryptedFields as $encryptedField) { if (strpos($encryptedField, '.') !== false) { $encryptedFieldSegments = explode('.', $encryptedField); $encryptedFieldSegment = array_shift($encryptedFieldSegments); if (!isset($controlValue[$encryptedFieldSegment])) { continue; } $valueReference = &$controlValue[$encryptedFieldSegment]; foreach ($encryptedFieldSegments as $encryptedFieldSegment) { if (!isset($valueReference[$encryptedFieldSegment])) { break; } $valueReference = &$valueReference[$encryptedFieldSegment]; $vaultCiphertext = strrev($valueReference[$encryptedField]); $valueReference[$encryptedField] = $vaultCiphertext; } unset($valueReference); } elseif (isset($controlValue[$encryptedField])) { $vaultCiphertext = strrev($controlValue[$encryptedField]); $controlValue[$encryptedField] = $vaultCiphertext; } } var_dump($controlValue);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 54
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 54
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 44
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 41
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 41
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 41
Branch analysis from position: 41
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 53
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 53
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
filename:       /in/VODih
function name:  (null)
number of ops:  59
compiled vars:  !0 = $controlValue, !1 = $encryptedFields, !2 = $encryptedField, !3 = $encryptedFieldSegments, !4 = $encryptedFieldSegment, !5 = $valueReference, !6 = $vaultCiphertext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   17     2      > FE_RESET_R                                       $9      !1, ->54
          3    > > FE_FETCH_R                                               $9, !2, ->54
   18     4    >   INIT_FCALL                                               'strpos'
          5        SEND_VAR                                                 !2
          6        SEND_VAL                                                 '.'
          7        DO_ICALL                                         $10     
          8        TYPE_CHECK                                  1018          $10
          9      > JMPZ                                                     ~11, ->44
   19    10    >   INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '.'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $12     
         14        ASSIGN                                                   !3, $12
   20    15        INIT_FCALL                                               'array_shift'
         16        SEND_REF                                                 !3
         17        DO_ICALL                                         $14     
         18        ASSIGN                                                   !4, $14
   22    19        ISSET_ISEMPTY_DIM_OBJ                         0  ~16     !0, !4
         20        BOOL_NOT                                         ~17     ~16
         21      > JMPZ                                                     ~17, ->23
   23    22    > > JMP                                                      ->3
   26    23    >   FETCH_DIM_W                                      $18     !0, !4
         24        ASSIGN_REF                                               !5, $18
   27    25      > FE_RESET_R                                       $20     !3, ->41
         26    > > FE_FETCH_R                                               $20, !4, ->41
   28    27    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~21     !5, !4
         28        BOOL_NOT                                         ~22     ~21
         29      > JMPZ                                                     ~22, ->31
   29    30    > > JMP                                                      ->41
   32    31    >   FETCH_DIM_W                                      $23     !5, !4
         32        ASSIGN_REF                                               !5, $23
   33    33        INIT_FCALL                                               'strrev'
         34        FETCH_DIM_R                                      ~25     !5, !2
         35        SEND_VAL                                                 ~25
         36        DO_ICALL                                         $26     
         37        ASSIGN                                                   !6, $26
   34    38        ASSIGN_DIM                                               !5, !2
         39        OP_DATA                                                  !6
   27    40      > JMP                                                      ->26
         41    >   FE_FREE                                                  $20
   36    42        UNSET_CV                                                 !5
         43      > JMP                                                      ->53
   37    44    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !2
         45      > JMPZ                                                     ~29, ->53
   38    46    >   INIT_FCALL                                               'strrev'
         47        FETCH_DIM_R                                      ~30     !0, !2
         48        SEND_VAL                                                 ~30
         49        DO_ICALL                                         $31     
         50        ASSIGN                                                   !6, $31
   39    51        ASSIGN_DIM                                               !0, !2
         52        OP_DATA                                                  !6
   17    53    > > JMP                                                      ->3
         54    >   FE_FREE                                                  $9
   43    55        INIT_FCALL                                               'var_dump'
         56        SEND_VAR                                                 !0
         57        DO_ICALL                                                 
         58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.36 ms | 1405 KiB | 23 Q