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); $temp = array_map(function($item){ return array_combine(['golfer'], $item); }, $temp); print_r($temp);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i2Tir
function name:  (null)
number of ops:  16
compiled vars:  !0 = $var, !1 = $temp
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                                             $3      
          5        ASSIGN                                                       !1, $3
   16     6        INIT_FCALL                                                   'array_map'
          7        DECLARE_LAMBDA_FUNCTION                              ~5      [0]
   18     8        SEND_VAL                                                     ~5
          9        SEND_VAR                                                     !1
   16    10        DO_ICALL                                             $6      
         11        ASSIGN                                                       !1, $6
   19    12        INIT_FCALL                                                   'print_r'
         13        SEND_VAR                                                     !1
         14        DO_ICALL                                                     
         15      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i2Tir
function name:  {closure:/in/i2Tir:16}
number of ops:  7
compiled vars:  !0 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   RECV                                                 !0      
   17     1        INIT_FCALL                                                   'array_combine'
          2        SEND_VAL                                                     <array>
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $1      
          5      > RETURN                                                       $1
   18     6*     > RETURN                                                       null

End of Dynamic Function 0

Function array_replace_keys:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 61) Position 1 = -2
filename:       /in/i2Tir
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:
143.85 ms | 2145 KiB | 18 Q