3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'index1' => 'Deleted', 'index2' => 'numbers', 'index3' => 'test', 'index4' => 'Inserted', ); $specificIndex = 'index2'; $array1=array(); foreach($array as $key => $value){ if($key==$specificIndex){ $array1[$key] = $value; unset($array[$specificIndex]); } } print_r($array); print_r($array1);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/G07FO
function name:  (null)
number of ops:  20
compiled vars:  !0 = $array, !1 = $specificIndex, !2 = $array1, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, 'index2'
   10     2        ASSIGN                                                   !2, <array>
   11     3      > FE_RESET_R                                       $8      !0, ->12
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->12
          5    >   ASSIGN                                                   !4, ~9
   12     6        IS_EQUAL                                                 !4, !1
          7      > JMPZ                                                     ~11, ->11
   13     8    >   ASSIGN_DIM                                               !2, !4
          9        OP_DATA                                                  !3
   14    10        UNSET_DIM                                                !0, !1
   11    11    > > JMP                                                      ->4
         12    >   FE_FREE                                                  $8
   17    13        INIT_FCALL                                               'print_r'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
   18    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
195.46 ms | 1395 KiB | 15 Q