3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getTableHtml(array $data, int $colLength): string { $result = ''; $rowNumber = 0; $rows = []; foreach (array_values($data) as $k => $v) { if ($k % $colLength === 0) { ++$rowNumber; $rows[$rowNumber] = ''; } $rows[$rowNumber] .= '<td>'; $rows[$rowNumber] .= htmlentities($v); $rows[$rowNumber] .= '</td>'; $rows[$rowNumber] .= PHP_EOL; // optional formatting } $result = '<table><tr>' . join('</tr><tr>', $rows) . '</tr></table>'; return $result; } $array = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ]; echo getTableHtml($array, 4), PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A7erq
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, <array>
   30     1        INIT_FCALL                                               'gettablehtml'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 4
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
          6        ECHO                                                     '%0A'
          7      > RETURN                                                   1

Function gettablehtml:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 29
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 29
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 17
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/A7erq
function name:  getTableHtml
number of ops:  41
compiled vars:  !0 = $data, !1 = $colLength, !2 = $result, !3 = $rowNumber, !4 = $rows, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, ''
    7     3        ASSIGN                                                   !3, 0
    8     4        ASSIGN                                                   !4, <array>
    9     5        INIT_FCALL                                               'array_values'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $10     
          8      > FE_RESET_R                                       $11     $10, ->29
          9    > > FE_FETCH_R                                       ~12     $11, !5, ->29
         10    >   ASSIGN                                                   !6, ~12
   10    11        MOD                                              ~14     !6, !1
         12        IS_IDENTICAL                                             ~14, 0
         13      > JMPZ                                                     ~15, ->17
   11    14    >   PRE_INC                                                  !3
   12    15        ASSIGN_DIM                                               !4, !3
         16        OP_DATA                                                  ''
   15    17    >   ASSIGN_DIM_OP                .=               8          !4, !3
         18        OP_DATA                                                  '%3Ctd%3E'
   16    19        INIT_FCALL                                               'htmlentities'
         20        SEND_VAR                                                 !5
         21        DO_ICALL                                         $20     
         22        ASSIGN_DIM_OP                .=               8          !4, !3
         23        OP_DATA                                                  $20
   17    24        ASSIGN_DIM_OP                .=               8          !4, !3
         25        OP_DATA                                                  '%3C%2Ftd%3E'
   18    26        ASSIGN_DIM_OP                .=               8          !4, !3
         27        OP_DATA                                                  '%0A'
    9    28      > JMP                                                      ->9
         29    >   FE_FREE                                                  $11
   21    30        INIT_FCALL                                               'join'
         31        SEND_VAL                                                 '%3C%2Ftr%3E%3Ctr%3E'
         32        SEND_VAR                                                 !4
         33        DO_ICALL                                         $23     
         34        CONCAT                                           ~24     '%3Ctable%3E%3Ctr%3E', $23
         35        CONCAT                                           ~25     ~24, '%3C%2Ftr%3E%3C%2Ftable%3E'
         36        ASSIGN                                                   !2, ~25
   23    37        VERIFY_RETURN_TYPE                                       !2
         38      > RETURN                                                   !2
   24    39*       VERIFY_RETURN_TYPE                                       
         40*     > RETURN                                                   null

End of function gettablehtml

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.75 ms | 1023 KiB | 17 Q