3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry'); reset($fruit); while (list($key, $val) = each($fruit)) { echo "$key => $val\n"; } foreach ($fruit as $key => $val) { echo "$key => $val\n"; } function my_each($array) { $key = key($array); if (!isset($key)) { return false; } $current = current($array); next($array); return [$key, $current]; } reset($fruit); while (list($key, $val) = each($fruit)) { echo "$key => $val\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 32
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 32
Branch analysis from position: 45
Branch analysis from position: 32
Branch analysis from position: 27
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 5
Branch analysis from position: 18
Branch analysis from position: 5
filename:       /in/6lL4a
function name:  (null)
number of ops:  46
compiled vars:  !0 = $fruit, !1 = $key, !2 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'reset'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
    6     4      > JMP                                                      ->10
    7     5    >   ROPE_INIT                                     4  ~6      !1
          6        ROPE_ADD                                      1  ~6      ~6, '+%3D%3E+'
          7        ROPE_ADD                                      2  ~6      ~6, !2
          8        ROPE_END                                      3  ~5      ~6, '%0A'
          9        ECHO                                                     ~5
    6    10    >   INIT_FCALL_BY_NAME                                       'each'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $8      
         13        FETCH_LIST_R                                     $9      $8, 0
         14        ASSIGN                                                   !1, $9
         15        FETCH_LIST_R                                     $11     $8, 1
         16        ASSIGN                                                   !2, $11
         17      > JMPNZ                                                    $8, ->5
   10    18    > > FE_RESET_R                                       $13     !0, ->27
         19    > > FE_FETCH_R                                       ~14     $13, !2, ->27
         20    >   ASSIGN                                                   !1, ~14
   11    21        ROPE_INIT                                     4  ~17     !1
         22        ROPE_ADD                                      1  ~17     ~17, '+%3D%3E+'
         23        ROPE_ADD                                      2  ~17     ~17, !2
         24        ROPE_END                                      3  ~16     ~17, '%0A'
         25        ECHO                                                     ~16
   10    26      > JMP                                                      ->19
         27    >   FE_FREE                                                  $13
   25    28        INIT_FCALL                                               'reset'
         29        SEND_REF                                                 !0
         30        DO_ICALL                                                 
   26    31      > JMP                                                      ->37
   27    32    >   ROPE_INIT                                     4  ~21     !1
         33        ROPE_ADD                                      1  ~21     ~21, '+%3D%3E+'
         34        ROPE_ADD                                      2  ~21     ~21, !2
         35        ROPE_END                                      3  ~20     ~21, '%0A'
         36        ECHO                                                     ~20
   26    37    >   INIT_FCALL_BY_NAME                                       'each'
         38        SEND_VAR_EX                                              !0
         39        DO_FCALL                                      0  $23     
         40        FETCH_LIST_R                                     $24     $23, 0
         41        ASSIGN                                                   !1, $24
         42        FETCH_LIST_R                                     $26     $23, 1
         43        ASSIGN                                                   !2, $26
         44      > JMPNZ                                                    $23, ->32
   28    45    > > RETURN                                                   1

Function my_each:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6lL4a
function name:  my_each
number of ops:  20
compiled vars:  !0 = $array, !1 = $key, !2 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'key'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
   17     5        ISSET_ISEMPTY_CV                                 ~5      !1
          6        BOOL_NOT                                         ~6      ~5
          7      > JMPZ                                                     ~6, ->9
   18     8    > > RETURN                                                   <false>
   20     9    >   INIT_FCALL                                               'current'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $7      
         12        ASSIGN                                                   !2, $7
   21    13        INIT_FCALL                                               'next'
         14        SEND_REF                                                 !0
         15        DO_ICALL                                                 
   22    16        INIT_ARRAY                                       ~10     !1
         17        ADD_ARRAY_ELEMENT                                ~10     !2
         18      > RETURN                                                   ~10
   23    19*     > RETURN                                                   null

End of function my_each

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.08 ms | 1400 KiB | 21 Q