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); $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}
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 = 79) Position 1 = -2
filename:       /in/i2Tir
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:
142.55 ms | 1013 KiB | 17 Q