3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [hoster,2,3,4,5,6,7,8,9,10,11,12]; function getIndexTranslator($list, $numColumns) { $numRows = ceil(count($list)/$numColumns); return function($x) use ($list, $numColumns, $numRows){ return ($x % $numColumns) * $numRows + floor($x / $numColumns); }; } $transformer = getIndexTranslator($arr, 4); for($x = 0; $x < count($arr); $x++){ echo $arr[$transformer($x)], $x % 4 == 3?"\n":" "; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 21
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 21
Branch analysis from position: 37
Branch analysis from position: 21
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 21
Branch analysis from position: 37
Branch analysis from position: 21
filename:       /in/pqn6I
function name:  (null)
number of ops:  38
compiled vars:  !0 = $arr, !1 = $transformer, !2 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_CONSTANT                                   ~3      'hoster'
          1        INIT_ARRAY                                       ~4      ~3
          2        ADD_ARRAY_ELEMENT                                ~4      2
          3        ADD_ARRAY_ELEMENT                                ~4      3
          4        ADD_ARRAY_ELEMENT                                ~4      4
          5        ADD_ARRAY_ELEMENT                                ~4      5
          6        ADD_ARRAY_ELEMENT                                ~4      6
          7        ADD_ARRAY_ELEMENT                                ~4      7
          8        ADD_ARRAY_ELEMENT                                ~4      8
          9        ADD_ARRAY_ELEMENT                                ~4      9
         10        ADD_ARRAY_ELEMENT                                ~4      10
         11        ADD_ARRAY_ELEMENT                                ~4      11
         12        ADD_ARRAY_ELEMENT                                ~4      12
         13        ASSIGN                                                   !0, ~4
   12    14        INIT_FCALL                                               'getindextranslator'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 4
         17        DO_FCALL                                      0  $6      
         18        ASSIGN                                                   !1, $6
   13    19        ASSIGN                                                   !2, 0
         20      > JMP                                                      ->34
   14    21    >   INIT_DYNAMIC_CALL                                        !1
         22        SEND_VAR_EX                                              !2
         23        DO_FCALL                                      0  $9      
         24        FETCH_DIM_R                                      ~10     !0, $9
         25        ECHO                                                     ~10
         26        MOD                                              ~11     !2, 4
         27        IS_EQUAL                                                 ~11, 3
         28      > JMPZ                                                     ~12, ->31
         29    >   QM_ASSIGN                                        ~13     '%0A'
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~13     '+'
         32    >   ECHO                                                     ~13
   13    33        PRE_INC                                                  !2
         34    >   COUNT                                            ~15     !0
         35        IS_SMALLER                                               !2, ~15
         36      > JMPNZ                                                    ~16, ->21
   15    37    > > RETURN                                                   1

Function getindextranslator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pqn6I
function name:  getIndexTranslator
number of ops:  14
compiled vars:  !0 = $list, !1 = $numColumns, !2 = $numRows
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'ceil'
          3        COUNT                                            ~3      !0
          4        DIV                                              ~4      ~3, !1
          5        SEND_VAL                                                 ~4
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !2, $5
    7     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fpqn6I%3A7%240'
          9        BIND_LEXICAL                                             ~7, !0
         10        BIND_LEXICAL                                             ~7, !1
         11        BIND_LEXICAL                                             ~7, !2
    9    12      > RETURN                                                   ~7
   10    13*     > RETURN                                                   null

End of function getindextranslator

Function %00%7Bclosure%7D%2Fin%2Fpqn6I%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pqn6I
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $x, !1 = $list, !2 = $numColumns, !3 = $numRows
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
    8     4        MOD                                              ~4      !0, !2
          5        MUL                                              ~5      !3, ~4
          6        INIT_FCALL                                               'floor'
          7        DIV                                              ~6      !0, !2
          8        SEND_VAL                                                 ~6
          9        DO_ICALL                                         $7      
         10        ADD                                              ~8      ~5, $7
         11      > RETURN                                                   ~8
    9    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fpqn6I%3A7%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.57 ms | 1403 KiB | 18 Q