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 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 8
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 8
Branch analysis from position: 24
Branch analysis from position: 8
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 8
Branch analysis from position: 24
Branch analysis from position: 8
filename:       /in/38kf5
function name:  (null)
number of ops:  25
compiled vars:  !0 = $arr, !1 = $transformer, !2 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'getindextranslator'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 4
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !1, $4
   13     6        ASSIGN                                                   !2, 0
          7      > JMP                                                      ->21
   14     8    >   INIT_DYNAMIC_CALL                                        !1
          9        SEND_VAR_EX                                              !2
         10        DO_FCALL                                      0  $7      
         11        FETCH_DIM_R                                      ~8      !0, $7
         12        ECHO                                                     ~8
         13        MOD                                              ~9      !2, 4
         14        IS_EQUAL                                                 ~9, 3
         15      > JMPZ                                                     ~10, ->18
         16    >   QM_ASSIGN                                        ~11     '%0A'
         17      > JMP                                                      ->19
         18    >   QM_ASSIGN                                        ~11     '+'
         19    >   ECHO                                                     ~11
   13    20        PRE_INC                                                  !2
         21    >   COUNT                                            ~13     !0
         22        IS_SMALLER                                               !2, ~13
         23      > JMPNZ                                                    ~14, ->8
   15    24    > > RETURN                                                   1

Function getindextranslator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/38kf5
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%2F38kf5%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%2F38kf5%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/38kf5
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%2F38kf5%3A7%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.34 ms | 1403 KiB | 18 Q