3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('ROWS_PER_PAGE', 10); function display_table($fields, $data, $rows, $page){ if(isset($_GET['page'])){ $page = $_GET['page']; } else { $page = 1; } $firstRecord = ($page - 1) * ROWS_PER_PAGE; $pageNumbers = ceil($rows / ROWS_PER_PAGE); echo '<div class="table-responsive w-75 mx-auto py-3"> <table class="table table-dark table-bordered table-sm"> <thead> <tr>'; foreach($fields as $key){ echo '<th class="py-2">' . $key . '</th>'; } echo '</tr> </thead> </tbody>'; $keys = array_keys($fields); $lastRecord = min($firstRecord + ROWS_PER_PAGE, $rows); for($record = $firstRecord; $record < $lastRecord; $record++){ $row = $data[$record]; echo '<tr>'; for($recordCount = 0; $recordCount < count($keys); $recordCount++){ $column = $keys[$recordCount]; echo '<td class="py-2">' . $row[$column] . '</td>'; } echo '</tr>'; } echo '</tbody> </table'; for($pages = 1; $pages <= $pageNumbers; $pages++){ echo '<a class="btn btn-dark mx-1" href=?page=' . $pages . '</a>'; } } $fields = array( "id" => "Id", "emailaddress" => "Email", "firstname" => "First Name", "lastname" => "Last Name", "salesperson" => "Salesperson", "phonenumber" => "Phone Number", "extension" => "Extension", "type" => "Type" ); $data = array( array('id' => 1, 'emailaddress' => 'user1@example.com', 'firstname' => 'User', 'lastname' => 'One', 'salesperson' => 'y', 'phonenumber' => '1235556789', 'extension' => '1', 'type' => 'a') , array('id' => 2, 'emailaddress' => 'user2@example.com', 'firstname' => 'User', 'lastname' => 'Two', 'salesperson' => 'y', 'phonenumber' => '1235556789', 'extension' => '2', 'type' => 'a') ); display_table($fields, $data, 2, 1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hq2qA
function name:  (null)
number of ops:  13
compiled vars:  !0 = $fields, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'ROWS_PER_PAGE'
          2        SEND_VAL                                                 10
          3        DO_ICALL                                                 
   50     4        ASSIGN                                                   !0, <array>
   61     5        ASSIGN                                                   !1, <array>
   66     6        INIT_FCALL                                               'display_table'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 2
         10        SEND_VAL                                                 1
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

Function display_table:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 44
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 70
Branch analysis from position: 70
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 66
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 72, Position 2 = 66
Branch analysis from position: 72
Branch analysis from position: 66
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 49
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 63, Position 2 = 44
Branch analysis from position: 63
Branch analysis from position: 44
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 59, Position 2 = 49
Branch analysis from position: 59
Branch analysis from position: 49
Branch analysis from position: 29
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
Branch analysis from position: 29
filename:       /in/hq2qA
function name:  display_table
number of ops:  73
compiled vars:  !0 = $fields, !1 = $data, !2 = $rows, !3 = $page, !4 = $firstRecord, !5 = $pageNumbers, !6 = $key, !7 = $keys, !8 = $lastRecord, !9 = $record, !10 = $row, !11 = $recordCount, !12 = $column, !13 = $pages
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    5     4        FETCH_IS                                         ~14     '_GET'
          5        ISSET_ISEMPTY_DIM_OBJ                         0          ~14, 'page'
          6      > JMPZ                                                     ~15, ->11
    6     7    >   FETCH_R                      global              ~16     '_GET'
          8        FETCH_DIM_R                                      ~17     ~16, 'page'
          9        ASSIGN                                                   !3, ~17
         10      > JMP                                                      ->12
    8    11    >   ASSIGN                                                   !3, 1
   10    12    >   SUB                                              ~20     !3, 1
         13        FETCH_CONSTANT                                   ~21     'ROWS_PER_PAGE'
         14        MUL                                              ~22     ~20, ~21
         15        ASSIGN                                                   !4, ~22
   11    16        INIT_FCALL                                               'ceil'
         17        FETCH_CONSTANT                                   ~24     'ROWS_PER_PAGE'
         18        DIV                                              ~25     !2, ~24
         19        SEND_VAL                                                 ~25
         20        DO_ICALL                                         $26     
         21        ASSIGN                                                   !5, $26
   13    22        ECHO                                                     '%3Cdiv+class%3D%22table-responsive+w-75+mx-auto+py-3%22%3E%0A++%3Ctable+class%3D%22table+table-dark+table-bordered+table-sm%22%3E%0A++%3Cthead%3E%0A++%3Ctr%3E'
   18    23      > FE_RESET_R                                       $28     !0, ->29
         24    > > FE_FETCH_R                                               $28, !6, ->29
   19    25    >   CONCAT                                           ~29     '%3Cth+class%3D%22py-2%22%3E', !6
         26        CONCAT                                           ~30     ~29, '%3C%2Fth%3E'
         27        ECHO                                                     ~30
   18    28      > JMP                                                      ->24
         29    >   FE_FREE                                                  $28
   22    30        ECHO                                                     '%3C%2Ftr%3E%0A++%3C%2Fthead%3E%0A++%3C%2Ftbody%3E'
   26    31        INIT_FCALL                                               'array_keys'
         32        SEND_VAR                                                 !0
         33        DO_ICALL                                         $31     
         34        ASSIGN                                                   !7, $31
   28    35        INIT_FCALL                                               'min'
         36        FETCH_CONSTANT                                   ~33     'ROWS_PER_PAGE'
         37        ADD                                              ~34     !4, ~33
         38        SEND_VAL                                                 ~34
         39        SEND_VAR                                                 !2
         40        DO_ICALL                                         $35     
         41        ASSIGN                                                   !8, $35
   30    42        ASSIGN                                                   !9, !4
         43      > JMP                                                      ->61
   31    44    >   FETCH_DIM_R                                      ~38     !1, !9
         45        ASSIGN                                                   !10, ~38
   32    46        ECHO                                                     '%3Ctr%3E'
   34    47        ASSIGN                                                   !11, 0
         48      > JMP                                                      ->56
   35    49    >   FETCH_DIM_R                                      ~41     !7, !11
         50        ASSIGN                                                   !12, ~41
   36    51        FETCH_DIM_R                                      ~43     !10, !12
         52        CONCAT                                           ~44     '%3Ctd+class%3D%22py-2%22%3E', ~43
         53        CONCAT                                           ~45     ~44, '%3C%2Ftd%3E'
         54        ECHO                                                     ~45
   34    55        PRE_INC                                                  !11
         56    >   COUNT                                            ~47     !7
         57        IS_SMALLER                                               !11, ~47
         58      > JMPNZ                                                    ~48, ->49
   39    59    >   ECHO                                                     '%3C%2Ftr%3E'
   30    60        PRE_INC                                                  !9
         61    >   IS_SMALLER                                               !9, !8
         62      > JMPNZ                                                    ~50, ->44
   42    63    >   ECHO                                                     '%3C%2Ftbody%3E%0A++%3C%2Ftable'
   45    64        ASSIGN                                                   !13, 1
         65      > JMP                                                      ->70
   46    66    >   CONCAT                                           ~52     '%3Ca+class%3D%22btn+btn-dark+mx-1%22+href%3D%3Fpage%3D', !13
         67        CONCAT                                           ~53     ~52, '%3C%2Fa%3E'
         68        ECHO                                                     ~53
   45    69        PRE_INC                                                  !13
         70    >   IS_SMALLER_OR_EQUAL                                      !13, !5
         71      > JMPNZ                                                    ~55, ->66
   48    72    > > RETURN                                                   null

End of function display_table

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.5 ms | 1406 KiB | 22 Q