3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_replace_keys($array, $keys) { print_r($keys);die; foreach ($keys as $search => $replace) { if ( isset($array[$search])) { $array[$replace] = $array[$search]; unset($array[$search]); } } return $array; } $var = '[{"player":"Tiger Woods"},{"player":"Gary Player"}]'; $temp = json_decode($var, true); foreach ($temp as $k => &$v){ $v['golfer'] = $v['player']; unset($v['player']); } print_r($temp);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 126) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/HeulP
function name:  (null)
number of ops:  19
compiled vars:  !0 = $var, !1 = $temp, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, '%5B%7B%22player%22%3A%22Tiger+Woods%22%7D%2C%7B%22player%22%3A%22Gary+Player%22%7D%5D'
   15     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   16     6      > FE_RESET_RW                                      $7      !1, ->14
          7    > > FE_FETCH_RW                                      ~8      $7, !2, ->14
          8    >   ASSIGN                                                   !3, ~8
   17     9        FETCH_DIM_R                                      ~11     !2, 'player'
         10        ASSIGN_DIM                                               !2, 'golfer'
         11        OP_DATA                                                  ~11
   18    12        UNSET_DIM                                                !2, 'player'
   16    13      > JMP                                                      ->7
         14    >   FE_FREE                                                  $7
   20    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function array_replace_keys:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/HeulP
function name:  array_replace_keys
number of ops:  19
compiled vars:  !0 = $array, !1 = $keys, !2 = $replace, !3 = $search
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                                 
          5      > EXIT                                                     
    5     6*       FE_RESET_R                                       $5      !1, ->16
          7*       FE_FETCH_R                                       ~6      $5, !2, ->16
          8*       ASSIGN                                                   !3, ~6
    6     9*       ISSET_ISEMPTY_DIM_OBJ                         0          !0, !3
         10*       JMPZ                                                     ~8, ->15
    7    11*       FETCH_DIM_R                                      ~10     !0, !3
         12*       ASSIGN_DIM                                               !0, !2
         13*       OP_DATA                                                  ~10
    8    14*       UNSET_DIM                                                !0, !3
    5    15*       JMP                                                      ->7
         16*       FE_FREE                                                  $5
   12    17*       RETURN                                                   !0
   13    18*     > RETURN                                                   null

End of function array_replace_keys

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.51 ms | 1011 KiB | 15 Q