3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_replace_key($search, $replace, array $target) { $return = array(); foreach ($target as $key => $val) { if ($search === $key) { $return[$replace] = $val; } else { $return[$key] = $val; } } return $return; } $a = array('a' => 'franz', 'b' => 'cheryl', 'c' => 'samantha'); var_dump(array_replace_key('a', 'b', $a));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OUoGL
function name:  (null)
number of ops:  10
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_replace_key'
          3        SEND_VAL                                                 'a'
          4        SEND_VAL                                                 'b'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function array_replace_key:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/OUoGL
function name:  array_replace_key
number of ops:  18
compiled vars:  !0 = $search, !1 = $replace, !2 = $target, !3 = $return, !4 = $val, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3        ASSIGN                                                   !3, <array>
    6     4      > FE_RESET_R                                       $7      !2, ->15
          5    > > FE_FETCH_R                                       ~8      $7, !4, ->15
          6    >   ASSIGN                                                   !5, ~8
    7     7        IS_IDENTICAL                                             !0, !5
          8      > JMPZ                                                     ~10, ->12
    8     9    >   ASSIGN_DIM                                               !3, !1
         10        OP_DATA                                                  !4
         11      > JMP                                                      ->14
   10    12    >   ASSIGN_DIM                                               !3, !5
         13        OP_DATA                                                  !4
    6    14    > > JMP                                                      ->5
         15    >   FE_FREE                                                  $7
   13    16      > RETURN                                                   !3
   14    17*     > RETURN                                                   null

End of function array_replace_key

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.48 ms | 1390 KiB | 16 Q