3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('name', 'name', 'email', 'name', 'address', 'phone', 'phone'); foreach ($array as $value) { $keys = array_keys($array, $value); // get rid of the first entry array_shift($keys); // add counters to duplicates for ($i = 0; $i < count($keys); $i++) { $array[$keys[$i]] = $value . "_" . ($i + 2); } } print_r($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 24
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 13
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 13
Branch analysis from position: 23
Branch analysis from position: 13
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/kpR0B
function name:  (null)
number of ops:  29
compiled vars:  !0 = $array, !1 = $value, !2 = $keys, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1      > FE_RESET_R                                       $5      !0, ->24
          2    > > FE_FETCH_R                                               $5, !1, ->24
    6     3    >   INIT_FCALL                                               'array_keys'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !2, $6
    8     8        INIT_FCALL                                               'array_shift'
          9        SEND_REF                                                 !2
         10        DO_ICALL                                                 
   10    11        ASSIGN                                                   !3, 0
         12      > JMP                                                      ->20
   11    13    >   FETCH_DIM_R                                      ~10     !2, !3
         14        CONCAT                                           ~12     !1, '_'
         15        ADD                                              ~13     !3, 2
         16        CONCAT                                           ~14     ~12, ~13
         17        ASSIGN_DIM                                               !0, ~10
         18        OP_DATA                                                  ~14
   10    19        PRE_INC                                                  !3
         20    >   COUNT                                            ~16     !2
         21        IS_SMALLER                                               !3, ~16
         22      > JMPNZ                                                    ~17, ->13
    5    23    > > JMP                                                      ->2
         24    >   FE_FREE                                                  $5
   14    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.8 ms | 1396 KiB | 19 Q