3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'Dup.A.123' => 1, 'D' => 4, ); $replacements = array( 'A.123' => 'A123', 'Dup.A' => 'DD', ); foreach (array_keys($array) as $key) { foreach ($replacements as $from => $to) { if (!strncmp($key, $from, strlen($from))) { $array[$to . substr($key, strlen($from))] = $array[$key]; unset($array[$key]); } } } print_r($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 31
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 31
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 29
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 29
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/gXDfP
function name:  (null)
number of ops:  36
compiled vars:  !0 = $array, !1 = $replacements, !2 = $key, !3 = $to, !4 = $from
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    6     1        ASSIGN                                                   !1, <array>
   10     2        INIT_FCALL                                               'array_keys'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5      > FE_RESET_R                                       $8      $7, ->31
          6    > > FE_FETCH_R                                               $8, !2, ->31
   11     7    > > FE_RESET_R                                       $9      !1, ->29
          8    > > FE_FETCH_R                                       ~10     $9, !3, ->29
          9    >   ASSIGN                                                   !4, ~10
   12    10        INIT_FCALL                                               'strncmp'
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !4
         13        STRLEN                                           ~12     !4
         14        SEND_VAL                                                 ~12
         15        DO_ICALL                                         $13     
         16        BOOL_NOT                                         ~14     $13
         17      > JMPZ                                                     ~14, ->28
   13    18    >   INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !2
         20        STRLEN                                           ~15     !4
         21        SEND_VAL                                                 ~15
         22        DO_ICALL                                         $16     
         23        CONCAT                                           ~17     !3, $16
         24        FETCH_DIM_R                                      ~19     !0, !2
         25        ASSIGN_DIM                                               !0, ~17
         26        OP_DATA                                                  ~19
   14    27        UNSET_DIM                                                !0, !2
   11    28    > > JMP                                                      ->8
         29    >   FE_FREE                                                  $9
   10    30      > JMP                                                      ->6
         31    >   FE_FREE                                                  $8
   18    32        INIT_FCALL                                               'print_r'
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.77 ms | 1400 KiB | 21 Q