3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [1, 2, 3]; // Ссылка $value на значение массива $array не удаляется после выхода из тела цикла и указывает на последний элемент массива. $array[2] также указывает на последний элемент. foreach ($array as &$value) { } // Каждый проход цикла устанавливается новое значение $value, к-рый указывает на последний элемент. foreach ($array as $key => $value) { echo "\$array[$key] = $array[$key]; \$array[3] = $array[3]; \$value = $value\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 21
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
Branch analysis from position: 4
filename:       /in/43CH7
function name:  (null)
number of ops:  23
compiled vars:  !0 = $array, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    6     1      > FE_RESET_RW                                      $4      !0, ->4
          2    > > FE_FETCH_RW                                              $4, !1, ->4
          3    > > JMP                                                      ->2
          4    >   FE_FREE                                                  $4
    9     5      > FE_RESET_R                                       $5      !0, ->21
          6    > > FE_FETCH_R                                       ~6      $5, !1, ->21
          7    >   ASSIGN                                                   !2, ~6
   10     8        ROPE_INIT                                     9  ~11     '%24array%5B'
          9        ROPE_ADD                                      1  ~11     ~11, !2
         10        ROPE_ADD                                      2  ~11     ~11, '%5D+%3D+'
         11        FETCH_DIM_R                                      ~8      !0, !2
         12        ROPE_ADD                                      3  ~11     ~11, ~8
         13        ROPE_ADD                                      4  ~11     ~11, '%3B+%24array%5B3%5D+%3D+'
         14        FETCH_DIM_R                                      ~9      !0, 3
         15        ROPE_ADD                                      5  ~11     ~11, ~9
         16        ROPE_ADD                                      6  ~11     ~11, '%3B+%24value+%3D+'
         17        ROPE_ADD                                      7  ~11     ~11, !1
         18        ROPE_END                                      8  ~10     ~11, '%0A'
         19        ECHO                                                     ~10
    9    20      > JMP                                                      ->6
         21    >   FE_FREE                                                  $5
   11    22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.13 ms | 1394 KiB | 13 Q