3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['a' => 'val1', 'b' => 'val2', 'c' => 'val3', 'd' => 'val4', 'e' => 'val5']; $swaps = ['a' => 'd', 'd' => 'a'/*, 'b' => 'e', 'e' => 'b'*/]; $result = []; foreach ($array as $k => $v) { if (!isset($swaps[$k], $array[$swaps[$k]])) { $result[$k] = $v; } else { $result[$swaps[$k]] = $array[$swaps[$k]]; } } var_export($result);
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 = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
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: 16
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/bqCm4
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array, !1 = $swaps, !2 = $result, !3 = $v, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    7     2        ASSIGN                                                   !2, <array>
    8     3      > FE_RESET_R                                       $8      !0, ->22
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->22
          5    >   ASSIGN                                                   !4, ~9
    9     6        ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !1, !4
          7      > JMPZ_EX                                          ~11     ~11, ->11
          8    >   FETCH_DIM_R                                      ~12     !1, !4
          9        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !0, ~12
         10        BOOL                                             ~11     ~13
         11    >   BOOL_NOT                                         ~14     ~11
         12      > JMPZ                                                     ~14, ->16
   10    13    >   ASSIGN_DIM                                               !2, !4
         14        OP_DATA                                                  !3
    9    15      > JMP                                                      ->21
   12    16    >   FETCH_DIM_R                                      ~16     !1, !4
         17        FETCH_DIM_R                                      ~18     !1, !4
         18        FETCH_DIM_R                                      ~19     !0, ~18
         19        ASSIGN_DIM                                               !2, ~16
         20        OP_DATA                                                  ~19
    8    21    > > JMP                                                      ->4
         22    >   FE_FREE                                                  $8
   16    23        INIT_FCALL                                               'var_export'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.4 ms | 1011 KiB | 14 Q