3v4l.org

run code in 300+ PHP versions simultaneously
<?php function map( $text = 'file', $elements = 5, $start = 1, $step = 1 ) { $end = $start + $elements * $step - 1; return array_map( fn($i) => $text . $i, range($start, $end, $step) ); } function whileloop( $text = 'file', $elements = 5, $start = 1, $step = 1 ) { $result = []; $end = $start + $elements * $step - 1; while ($start <= $end) { $result[] = $text . $start; $start += $step; } return $result; } function forloop( $text = 'file', $elements = 5, $start = 1, $step = 1 ) { $result = []; for ($i = 0; $i < $elements; ++$i, $start += $step) { $result[] = $text . $start; } return $result; } var_export(map()); echo "\n---\n"; var_export(whileloop()); echo "\n---\n"; var_export(forloop()); echo "\n---\n"; var_export(map('file', 5, 4, 20)); echo "\n---\n"; var_export(whileloop('file', 5, 4, 20)); echo "\n---\n"; var_export(forloop('file', 5, 4, 20)); echo "\n---\n"; var_export(map('file', 2)); echo "\n---\n"; var_export(whileloop('file', 2)); echo "\n---\n"; var_export(forloop('file', 2)); echo "\n---\n"; var_export(map('file', 3, 3, 7)); echo "\n---\n"; var_export(whileloop('file', 3, 3, 7)); echo "\n---\n"; var_export(forloop('file', 3, 3, 7)); echo "\n---\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bs7gI
function name:  (null)
number of ops:  103
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   INIT_FCALL                                               'var_export'
          1        INIT_FCALL                                               'map'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
   45     5        ECHO                                                     '%0A---%0A'
   46     6        INIT_FCALL                                               'var_export'
          7        INIT_FCALL                                               'whileloop'
          8        DO_FCALL                                      0  $2      
          9        SEND_VAR                                                 $2
         10        DO_ICALL                                                 
   47    11        ECHO                                                     '%0A---%0A'
   48    12        INIT_FCALL                                               'var_export'
         13        INIT_FCALL                                               'forloop'
         14        DO_FCALL                                      0  $4      
         15        SEND_VAR                                                 $4
         16        DO_ICALL                                                 
   49    17        ECHO                                                     '%0A---%0A'
   50    18        INIT_FCALL                                               'var_export'
         19        INIT_FCALL                                               'map'
         20        SEND_VAL                                                 'file'
         21        SEND_VAL                                                 5
         22        SEND_VAL                                                 4
         23        SEND_VAL                                                 20
         24        DO_FCALL                                      0  $6      
         25        SEND_VAR                                                 $6
         26        DO_ICALL                                                 
   51    27        ECHO                                                     '%0A---%0A'
   52    28        INIT_FCALL                                               'var_export'
         29        INIT_FCALL                                               'whileloop'
         30        SEND_VAL                                                 'file'
         31        SEND_VAL                                                 5
         32        SEND_VAL                                                 4
         33        SEND_VAL                                                 20
         34        DO_FCALL                                      0  $8      
         35        SEND_VAR                                                 $8
         36        DO_ICALL                                                 
   53    37        ECHO                                                     '%0A---%0A'
   54    38        INIT_FCALL                                               'var_export'
         39        INIT_FCALL                                               'forloop'
         40        SEND_VAL                                                 'file'
         41        SEND_VAL                                                 5
         42        SEND_VAL                                                 4
         43        SEND_VAL                                                 20
         44        DO_FCALL                                      0  $10     
         45        SEND_VAR                                                 $10
         46        DO_ICALL                                                 
   55    47        ECHO                                                     '%0A---%0A'
   56    48        INIT_FCALL                                               'var_export'
         49        INIT_FCALL                                               'map'
         50        SEND_VAL                                                 'file'
         51        SEND_VAL                                                 2
         52        DO_FCALL                                      0  $12     
         53        SEND_VAR                                                 $12
         54        DO_ICALL                                                 
   57    55        ECHO                                                     '%0A---%0A'
   58    56        INIT_FCALL                                               'var_export'
         57        INIT_FCALL                                               'whileloop'
         58        SEND_VAL                                                 'file'
         59        SEND_VAL                                                 2
         60        DO_FCALL                                      0  $14     
         61        SEND_VAR                                                 $14
         62        DO_ICALL                                                 
   59    63        ECHO                                                     '%0A---%0A'
   60    64        INIT_FCALL                                               'var_export'
         65        INIT_FCALL                                               'forloop'
         66        SEND_VAL                                                 'file'
         67        SEND_VAL                                                 2
         68        DO_FCALL                                      0  $16     
         69        SEND_VAR                                                 $16
         70        DO_ICALL                                                 
   61    71        ECHO                                                     '%0A---%0A'
   62    72        INIT_FCALL                                               'var_export'
         73        INIT_FCALL                                               'map'
         74        SEND_VAL                                                 'file'
         75        SEND_VAL                                                 3
         76        SEND_VAL                                                 3
         77        SEND_VAL                                                 7
         78        DO_FCALL                                      0  $18     
         79        SEND_VAR                                                 $18
         80        DO_ICALL                                                 
   63    81        ECHO                                                     '%0A---%0A'
   64    82        INIT_FCALL                                               'var_export'
         83        INIT_FCALL                                               'whileloop'
         84        SEND_VAL                                                 'file'
         85        SEND_VAL                                                 3
         86        SEND_VAL                                                 3
         87        SEND_VAL                                                 7
         88        DO_FCALL                                      0  $20     
         89        SEND_VAR                                                 $20
         90        DO_ICALL                                                 
   65    91        ECHO                                                     '%0A---%0A'
   66    92        INIT_FCALL                                               'var_export'
         93        INIT_FCALL                                               'forloop'
         94        SEND_VAL                                                 'file'
         95        SEND_VAL                                                 3
         96        SEND_VAL                                                 3
         97        SEND_VAL                                                 7
         98        DO_FCALL                                      0  $22     
         99        SEND_VAR                                                 $22
        100        DO_ICALL                                                 
   67   101        ECHO                                                     '%0A---%0A'
        102      > RETURN                                                   1

Function map:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bs7gI
function name:  map
number of ops:  21
compiled vars:  !0 = $text, !1 = $elements, !2 = $start, !3 = $step, !4 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      'file'
          1        RECV_INIT                                        !1      5
          2        RECV_INIT                                        !2      1
          3        RECV_INIT                                        !3      1
    9     4        MUL                                              ~5      !1, !3
          5        ADD                                              ~6      !2, ~5
          6        SUB                                              ~7      ~6, 1
          7        ASSIGN                                                   !4, ~7
   10     8        INIT_FCALL                                               'array_map'
   11     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fbs7gI%3A11%240'
         10        BIND_LEXICAL                                             ~9, !0
         11        SEND_VAL                                                 ~9
   12    12        INIT_FCALL                                               'range'
         13        SEND_VAR                                                 !2
         14        SEND_VAR                                                 !4
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $10     
         17        SEND_VAR                                                 $10
         18        DO_ICALL                                         $11     
         19      > RETURN                                                   $11
   14    20*     > RETURN                                                   null

End of function map

Function %00%7Bclosure%7D%2Fin%2Fbs7gI%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bs7gI
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $i, !1 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        CONCAT                                           ~2      !1, !0
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fbs7gI%3A11%240

Function whileloop:
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 = 16, Position 2 = 10
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 10
Branch analysis from position: 16
Branch analysis from position: 10
filename:       /in/bs7gI
function name:  whileloop
number of ops:  18
compiled vars:  !0 = $text, !1 = $elements, !2 = $start, !3 = $step, !4 = $result, !5 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV_INIT                                        !0      'file'
          1        RECV_INIT                                        !1      5
          2        RECV_INIT                                        !2      1
          3        RECV_INIT                                        !3      1
   22     4        ASSIGN                                                   !4, <array>
   23     5        MUL                                              ~7      !1, !3
          6        ADD                                              ~8      !2, ~7
          7        SUB                                              ~9      ~8, 1
          8        ASSIGN                                                   !5, ~9
   24     9      > JMP                                                      ->14
   25    10    >   CONCAT                                           ~12     !0, !2
         11        ASSIGN_DIM                                               !4
         12        OP_DATA                                                  ~12
   26    13        ASSIGN_OP                                     1          !2, !3
   24    14    >   IS_SMALLER_OR_EQUAL                                      !2, !5
         15      > JMPNZ                                                    ~14, ->10
   28    16    > > RETURN                                                   !4
   29    17*     > RETURN                                                   null

End of function whileloop

Function forloop:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 7
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 7
Branch analysis from position: 14
Branch analysis from position: 7
filename:       /in/bs7gI
function name:  forloop
number of ops:  16
compiled vars:  !0 = $text, !1 = $elements, !2 = $start, !3 = $step, !4 = $result, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV_INIT                                        !0      'file'
          1        RECV_INIT                                        !1      5
          2        RECV_INIT                                        !2      1
          3        RECV_INIT                                        !3      1
   37     4        ASSIGN                                                   !4, <array>
   38     5        ASSIGN                                                   !5, 0
          6      > JMP                                                      ->12
   39     7    >   CONCAT                                           ~9      !0, !2
          8        ASSIGN_DIM                                               !4
          9        OP_DATA                                                  ~9
   38    10        PRE_INC                                                  !5
         11        ASSIGN_OP                                     1          !2, !3
         12    >   IS_SMALLER                                               !5, !1
         13      > JMPNZ                                                    ~12, ->7
   41    14    > > RETURN                                                   !4
   42    15*     > RETURN                                                   null

End of function forloop

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.57 ms | 1415 KiB | 31 Q