3v4l.org

run code in 300+ PHP versions simultaneously
<?php function replace_array_values(array $data, array $replacements) { $result = []; foreach ($data as $k => $value) { if (array_key_exists($value, $replacements)) { $value = $replacements[$value]; } $result[$k] = $value; } return $result; } $data = array( 'a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D', ); $replacements = array( 'B' => '(B)', 'D' => '(D)', ); $expected_result = array( 'a' => 'A', 'b' => '(B)', 'c' => 'C', 'd' => '(D)', ); var_export($expected_result === replace_array_values($data, $replacements));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g0sIJ
function name:  (null)
number of ops:  12
compiled vars:  !0 = $data, !1 = $replacements, !2 = $expected_result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, <array>
   26     2        ASSIGN                                                   !2, <array>
   33     3        INIT_FCALL                                               'var_export'
          4        INIT_FCALL                                               'replace_array_values'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0  $6      
          8        IS_IDENTICAL                                     ~7      !2, $6
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

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

End of function replace_array_values

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.59 ms | 1001 KiB | 15 Q