3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ "k0"=>"v0", "k1"=>"v1", "k2"=>"v2", "k3"=>"v3", "k4"=>"v4", ]; $result_1 = []; while (key($data)) { $result_1[key($data)] = current($data); next($data); } print_r($result_1); //Then perform the same operation in a function supplying the same array $data as argument //(mind that the internal pointer of $data is at the end): traverse($data); function traverse($arr){ $result_2 = []; while (key($arr)) { $result_2[key($arr)] = current($arr); next($arr); } print_r($result_2); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
Branch analysis from position: 3
filename:       /in/YNJ18
function name:  (null)
number of ops:  25
compiled vars:  !0 = $data, !1 = $result_1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   12     2      > JMP                                                      ->14
   13     3    >   INIT_FCALL                                               'key'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        INIT_FCALL                                               'current'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $6      
          9        ASSIGN_DIM                                               !1, $4
         10        OP_DATA                                                  $6
   14    11        INIT_FCALL                                               'next'
         12        SEND_REF                                                 !0
         13        DO_ICALL                                                 
   12    14    >   INIT_FCALL                                               'key'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $8      
         17      > JMPNZ                                                    $8, ->3
   16    18    >   INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
   21    21        INIT_FCALL_BY_NAME                                       'traverse'
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0          
   30    24      > RETURN                                                   1

Function traverse:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 3
Branch analysis from position: 18
Branch analysis from position: 3
filename:       /in/YNJ18
function name:  traverse
number of ops:  22
compiled vars:  !0 = $arr, !1 = $result_2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   24     1        ASSIGN                                                   !1, <array>
   25     2      > JMP                                                      ->14
   26     3    >   INIT_FCALL                                               'key'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        INIT_FCALL                                               'current'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $5      
          9        ASSIGN_DIM                                               !1, $3
         10        OP_DATA                                                  $5
   27    11        INIT_FCALL                                               'next'
         12        SEND_REF                                                 !0
         13        DO_ICALL                                                 
   25    14    >   INIT_FCALL                                               'key'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $7      
         17      > JMPNZ                                                    $7, ->3
   29    18    >   INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
   30    21      > RETURN                                                   null

End of function traverse

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.8 ms | 1400 KiB | 21 Q