3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [1, 2, 3, 4, 5]; // Ссылка $value на значение массива $array не удаляется после выхода из тела цикла и указывает на последний элемент массива. $array[2] также указывает на последний элемент. foreach ($array as &$value) { } // Каждый проход цикла устанавливается новое значение $value, к-рый указывает на последний элемент. foreach ($array as $key => $value) { echo 'Iteration #' . $key . ":\n"; echo '$value = ' . $value . ";\n"; echo '$array = [' . implode($array) . "];\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/LnsOm
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        CONCAT                                           ~8      'Iteration+%23', !2
          9        CONCAT                                           ~9      ~8, '%3A%0A'
         10        ECHO                                                     ~9
   11    11        CONCAT                                           ~10     '%24value+%3D+', !1
         12        CONCAT                                           ~11     ~10, '%3B%0A'
         13        ECHO                                                     ~11
   12    14        INIT_FCALL                                               'implode'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $12     
         17        CONCAT                                           ~13     '%24array+%3D+%5B', $12
         18        CONCAT                                           ~14     ~13, '%5D%3B%0A'
         19        ECHO                                                     ~14
    9    20      > JMP                                                      ->6
         21    >   FE_FREE                                                  $5
   13    22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.72 ms | 1395 KiB | 15 Q