3v4l.org

run code in 300+ PHP versions simultaneously
<?php function has_next($array) { return next($array) === false && key($array) === null ? false : true; } $array1 = [ "one" => 1, "two" => 2, "three" => 3, "four" => 4 ]; while (has_next($array1)) { $current = current($array1); $key = key($array1); echo "$key => $current\n"; if ($current < 2) { $array1[$key] = ++$current; } else { next($array1); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 21
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 2
Branch analysis from position: 28
Branch analysis from position: 2
filename:       /in/8MlBG
function name:  (null)
number of ops:  29
compiled vars:  !0 = $array1, !1 = $current, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, <array>
   13     1      > JMP                                                      ->24
   14     2    >   INIT_FCALL                                               'current'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   15     6        INIT_FCALL                                               'key'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !2, $6
   16    10        ROPE_INIT                                     4  ~9      !2
         11        ROPE_ADD                                      1  ~9      ~9, '+%3D%3E+'
         12        ROPE_ADD                                      2  ~9      ~9, !1
         13        ROPE_END                                      3  ~8      ~9, '%0A'
         14        ECHO                                                     ~8
   17    15        IS_SMALLER                                               !1, 2
         16      > JMPZ                                                     ~11, ->21
   18    17    >   PRE_INC                                          ~13     !1
         18        ASSIGN_DIM                                               !0, !2
         19        OP_DATA                                                  ~13
         20      > JMP                                                      ->24
   20    21    >   INIT_FCALL                                               'next'
         22        SEND_REF                                                 !0
         23        DO_ICALL                                                 
   13    24    >   INIT_FCALL                                               'has_next'
         25        SEND_VAR                                                 !0
         26        DO_FCALL                                      0  $15     
         27      > JMPNZ                                                    $15, ->2
   22    28    > > RETURN                                                   1

Function has_next:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/8MlBG
function name:  has_next
number of ops:  17
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'next'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                         $1      
          4        TYPE_CHECK                                    4  ~2      $1
          5      > JMPZ_EX                                          ~2      ~2, ->11
          6    >   INIT_FCALL                                               'key'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $3      
          9        TYPE_CHECK                                    2  ~4      $3
         10        BOOL                                             ~2      ~4
         11    > > JMPZ                                                     ~2, ->14
         12    >   QM_ASSIGN                                        ~5      <false>
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~5      <true>
         15    > > RETURN                                                   ~5
    4    16*     > RETURN                                                   null

End of function has_next

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.15 ms | 1403 KiB | 20 Q