3v4l.org

run code in 500+ 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 = 61) Position 1 = -2
filename:       /in/HeulP
function name:  array_replace_keys
number of ops:  20
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      > INIT_FCALL                                                   'exit'
          6*       DO_ICALL                                                     
    5     7*       FE_RESET_R                                           $6      !1, ->17
          8*       FE_FETCH_R                                           ~7      $6, !2, ->17
          9*       ASSIGN                                                       !3, ~7
    6    10*       ISSET_ISEMPTY_DIM_OBJ                             0          !0, !3
         11*       JMPZ                                                         ~9, ->16
    7    12*       FETCH_DIM_R                                          ~11     !0, !3
         13*       ASSIGN_DIM                                                   !0, !2
         14*       OP_DATA                                                      ~11
    8    15*       UNSET_DIM                                                    !0, !3
    5    16*       JMP                                                          ->8
         17*       FE_FREE                                                      $6
   12    18*       RETURN                                                       !0
   13    19*     > RETURN                                                       null

End of function array_replace_keys

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.27 ms | 2299 KiB | 16 Q