3v4l.org

run code in 300+ PHP versions simultaneously
<?php class tableutils{ static function compareByName($a, $b){ return strcmp($a, $b); } static function tabella_riassunto ($valori,$cell1,$sort=true,$arr=false,$className='tabella_riassunto',$tot_righe=true,$classi="",$links=""){ /* Scorro l'array per trovare tutte le colonne possibili * TODO: esiste un modo piĆ¹ elegante? */ foreach ($valori as $key => $val) { foreach ($val as $kr => $vr) $col[$kr] = $kr; } if($sort) { sort($col); uksort($valori, 'tableutils::compareByName'); } /* Inizio a scrivere la tabella*/ $table="<table class=\"$className\" celpadding=\"0\" cellspacing=\"0\">"; /* Scrivo le intestazioni */ $table .="<tr>"; $table .="<th>$cell1</th>"; $rex[0][] = $cell1; /* Scrivo le intestazioni */ foreach ($col as $c) { $table .="<th>".$c."</th>";$rex[0][] = $c; } /* Questa colonna serve per i totali */ if($tot_righe) $table .="<th>TOTALE</th>"; //else $table .="<th></th>"; $table .="</tr>"; if($tot_righe)$rex[0][] = "TOTALE"; /* Ciclo l'array*/ $count = 1; foreach ($valori as $key => $val) { $tot1=0; $table .="<tr>"; $table .="<td class=\"nomi\">".$key."</td>"; $rex[$count][] = $key; $count_col=1; foreach ($col as $c){ if(is_array(links)){ if($links[$key][$c]){ if($classi[$count_col]) $table .="<td class=\"".$classi[$count_col]."\"><a href='".$links[$key][$c]."'>".$val[$c]."</a></td>"; else $table .="<td><a href='".$links[$key][$c]."'>".$val[$c]."</a></td>"; } else { if($classi[$count_col]) $table .="<td class=\"".$classi[$count_col]."\">".$val[$c]."</td>"; else $table .="<td>".$val[$c]."</td>"; } } $rex[$count][] = $val[$c]; /* Faccio la somma dei valori degli elementi della riga */ $tot1 += $val[$c]; /* Faccio la somma usando come indice il nome della colonna */ $tot2[$c] += $val[$c]; $count_col++; } if($tot_righe){ $table .="<td class=\"tot1\">".$tot1."</td>"; //else $table .="<td class=\"tot1\"></td>"; $rex[$count][] = $tot1; } $table .="</tr>"; $count++; } /* Scrivo la somma salvata precedentemente*/ $table .="<tr>"; $table .="<td class=\"tot1\">TOTALE</td>"; $rex[$count][] = "TOTALE"; foreach ($tot2 as $t){ $table .="<td class=\"tot1\">".$t."</td>"; $rex[$count][] = $t; $tot += $t; } if($tot_righe){ $table .="<td class=\"totfinal\">".$tot."</td>"; $rex[$count][] = $tot; } $table .="</tr>"; $table .="</table>"; if($arr) return $rex; else return $table; } } $arr = array("052 VARICELLA" => array("2015 m focolai" => 1, "2015 casi coinvolti" => 3)); tableutils::tabella_riassunto($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NPAiT
function name:  (null)
number of ops:  5
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   96     0  E >   ASSIGN                                                   !0, <array>
   98     1        INIT_STATIC_METHOD_CALL                                  'tableutils', 'tabella_riassunto'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Class tableutils:
Function comparebyname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NPAiT
function name:  compareByName
number of ops:  8
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'strcmp'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
    7     7*     > RETURN                                                   null

End of function comparebyname

Function tabella_riassunto:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 17
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 28
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 49
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 49
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 52
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 57
Branch analysis from position: 54
2 jumps found. (Code = 77) Position 1 = 59, Position 2 = 137
Branch analysis from position: 59
2 jumps found. (Code = 78) Position 1 = 60, Position 2 = 137
Branch analysis from position: 60
2 jumps found. (Code = 77) Position 1 = 71, Position 2 = 126
Branch analysis from position: 71
2 jumps found. (Code = 78) Position 1 = 72, Position 2 = 126
Branch analysis from position: 72
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 115
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 101
Branch analysis from position: 78
2 jumps found. (Code = 43) Position 1 = 80, Position 2 = 92
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
1 jumps found. (Code = 42) Position 1 = 115
Branch analysis from position: 115
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
Branch analysis from position: 92
1 jumps found. (Code = 42) Position 1 = 115
Branch analysis from position: 115
Branch analysis from position: 101
2 jumps found. (Code = 43) Position 1 = 103, Position 2 = 111
Branch analysis from position: 103
1 jumps found. (Code = 42) Position 1 = 115
Branch analysis from position: 115
Branch analysis from position: 111
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
Branch analysis from position: 115
Branch analysis from position: 126
2 jumps found. (Code = 43) Position 1 = 128, Position 2 = 134
Branch analysis from position: 128
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 134
Branch analysis from position: 126
Branch analysis from position: 137
2 jumps found. (Code = 77) Position 1 = 144, Position 2 = 153
Branch analysis from position: 144
2 jumps found. (Code = 78) Position 1 = 145, Position 2 = 153
Branch analysis from position: 145
1 jumps found. (Code = 42) Position 1 = 144
Branch analysis from position: 144
Branch analysis from position: 153
2 jumps found. (Code = 43) Position 1 = 155, Position 2 = 161
Branch analysis from position: 155
2 jumps found. (Code = 43) Position 1 = 164, Position 2 = 166
Branch analysis from position: 164
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 166
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 161
Branch analysis from position: 153
Branch analysis from position: 137
Branch analysis from position: 57
Branch analysis from position: 52
Branch analysis from position: 49
Branch analysis from position: 28
Branch analysis from position: 19
filename:       /in/NPAiT
function name:  tabella_riassunto
number of ops:  168
compiled vars:  !0 = $valori, !1 = $cell1, !2 = $sort, !3 = $arr, !4 = $className, !5 = $tot_righe, !6 = $classi, !7 = $links, !8 = $val, !9 = $key, !10 = $vr, !11 = $kr, !12 = $col, !13 = $table, !14 = $rex, !15 = $c, !16 = $count, !17 = $tot1, !18 = $count_col, !19 = $tot2, !20 = $t, !21 = $tot
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <true>
          3        RECV_INIT                                        !3      <false>
          4        RECV_INIT                                        !4      'tabella_riassunto'
          5        RECV_INIT                                        !5      <true>
          6        RECV_INIT                                        !6      ''
          7        RECV_INIT                                        !7      ''
   14     8      > FE_RESET_R                                       $22     !0, ->19
          9    > > FE_FETCH_R                                       ~23     $22, !8, ->19
         10    >   ASSIGN                                                   !9, ~23
         11      > FE_RESET_R                                       $25     !8, ->17
         12    > > FE_FETCH_R                                       ~26     $25, !10, ->17
         13    >   ASSIGN                                                   !11, ~26
         14        ASSIGN_DIM                                               !12, !11
         15        OP_DATA                                                  !11
         16      > JMP                                                      ->12
         17    >   FE_FREE                                                  $25
         18      > JMP                                                      ->9
         19    >   FE_FREE                                                  $22
   16    20      > JMPZ                                                     !2, ->28
   17    21    >   INIT_FCALL                                               'sort'
         22        SEND_REF                                                 !12
         23        DO_ICALL                                                 
   18    24        INIT_FCALL                                               'uksort'
         25        SEND_REF                                                 !0
         26        SEND_VAL                                                 'tableutils%3A%3AcompareByName'
         27        DO_ICALL                                                 
   22    28    >   ROPE_INIT                                     3  ~32     '%3Ctable+class%3D%22'
         29        ROPE_ADD                                      1  ~32     ~32, !4
         30        ROPE_END                                      2  ~31     ~32, '%22+celpadding%3D%220%22+cellspacing%3D%220%22%3E'
         31        ASSIGN                                                   !13, ~31
   25    32        ASSIGN_OP                                     8          !13, '%3Ctr%3E'
   26    33        ROPE_INIT                                     3  ~37     '%3Cth%3E'
         34        ROPE_ADD                                      1  ~37     ~37, !1
         35        ROPE_END                                      2  ~36     ~37, '%3C%2Fth%3E'
         36        ASSIGN_OP                                     8          !13, ~36
   27    37        FETCH_DIM_W                                      $40     !14, 0
         38        ASSIGN_DIM                                               $40
         39        OP_DATA                                                  !1
   30    40      > FE_RESET_R                                       $42     !12, ->49
         41    > > FE_FETCH_R                                               $42, !15, ->49
         42    >   CONCAT                                           ~43     '%3Cth%3E', !15
         43        CONCAT                                           ~44     ~43, '%3C%2Fth%3E'
         44        ASSIGN_OP                                     8          !13, ~44
         45        FETCH_DIM_W                                      $46     !14, 0
         46        ASSIGN_DIM                                               $46
         47        OP_DATA                                                  !15
         48      > JMP                                                      ->41
         49    >   FE_FREE                                                  $42
   32    50      > JMPZ                                                     !5, ->52
         51    >   ASSIGN_OP                                     8          !13, '%3Cth%3ETOTALE%3C%2Fth%3E'
   34    52    >   ASSIGN_OP                                     8          !13, '%3C%2Ftr%3E'
   35    53      > JMPZ                                                     !5, ->57
         54    >   FETCH_DIM_W                                      $50     !14, 0
         55        ASSIGN_DIM                                               $50
         56        OP_DATA                                                  'TOTALE'
   37    57    >   ASSIGN                                                   !16, 1
   38    58      > FE_RESET_R                                       $53     !0, ->137
         59    > > FE_FETCH_R                                       ~54     $53, !8, ->137
         60    >   ASSIGN                                                   !9, ~54
   39    61        ASSIGN                                                   !17, 0
   40    62        ASSIGN_OP                                     8          !13, '%3Ctr%3E'
   41    63        CONCAT                                           ~58     '%3Ctd+class%3D%22nomi%22%3E', !9
         64        CONCAT                                           ~59     ~58, '%3C%2Ftd%3E'
         65        ASSIGN_OP                                     8          !13, ~59
   42    66        FETCH_DIM_W                                      $61     !14, !16
         67        ASSIGN_DIM                                               $61
         68        OP_DATA                                                  !9
   43    69        ASSIGN                                                   !18, 1
   44    70      > FE_RESET_R                                       $64     !12, ->126
         71    > > FE_FETCH_R                                               $64, !15, ->126
   46    72    >   FETCH_CONSTANT                                   ~65     'links'
         73        TYPE_CHECK                                  128          ~65
         74      > JMPZ                                                     ~66, ->115
   47    75    >   FETCH_DIM_R                                      ~67     !7, !9
         76        FETCH_DIM_R                                      ~68     ~67, !15
         77      > JMPZ                                                     ~68, ->101
   48    78    >   FETCH_DIM_R                                      ~69     !6, !18
         79      > JMPZ                                                     ~69, ->92
         80    >   FETCH_DIM_R                                      ~70     !6, !18
         81        CONCAT                                           ~71     '%3Ctd+class%3D%22', ~70
         82        CONCAT                                           ~72     ~71, '%22%3E%3Ca++href%3D%27'
         83        FETCH_DIM_R                                      ~73     !7, !9
         84        FETCH_DIM_R                                      ~74     ~73, !15
         85        CONCAT                                           ~75     ~72, ~74
         86        CONCAT                                           ~76     ~75, '%27%3E'
         87        FETCH_DIM_R                                      ~77     !8, !15
         88        CONCAT                                           ~78     ~76, ~77
         89        CONCAT                                           ~79     ~78, '%3C%2Fa%3E%3C%2Ftd%3E'
         90        ASSIGN_OP                                     8          !13, ~79
         91      > JMP                                                      ->100
   49    92    >   FETCH_DIM_R                                      ~81     !7, !9
         93        FETCH_DIM_R                                      ~82     ~81, !15
         94        CONCAT                                           ~83     '%3Ctd%3E%3Ca+href%3D%27', ~82
         95        CONCAT                                           ~84     ~83, '%27%3E'
         96        FETCH_DIM_R                                      ~85     !8, !15
         97        CONCAT                                           ~86     ~84, ~85
         98        CONCAT                                           ~87     ~86, '%3C%2Fa%3E%3C%2Ftd%3E'
         99        ASSIGN_OP                                     8          !13, ~87
        100    > > JMP                                                      ->115
   52   101    >   FETCH_DIM_R                                      ~89     !6, !18
        102      > JMPZ                                                     ~89, ->111
        103    >   FETCH_DIM_R                                      ~90     !6, !18
        104        CONCAT                                           ~91     '%3Ctd+class%3D%22', ~90
        105        CONCAT                                           ~92     ~91, '%22%3E'
        106        FETCH_DIM_R                                      ~93     !8, !15
        107        CONCAT                                           ~94     ~92, ~93
        108        CONCAT                                           ~95     ~94, '%3C%2Ftd%3E'
        109        ASSIGN_OP                                     8          !13, ~95
        110      > JMP                                                      ->115
   53   111    >   FETCH_DIM_R                                      ~97     !8, !15
        112        CONCAT                                           ~98     '%3Ctd%3E', ~97
        113        CONCAT                                           ~99     ~98, '%3C%2Ftd%3E'
        114        ASSIGN_OP                                     8          !13, ~99
   56   115    >   FETCH_DIM_R                                      ~103    !8, !15
        116        FETCH_DIM_W                                      $101    !14, !16
        117        ASSIGN_DIM                                               $101
        118        OP_DATA                                                  ~103
   58   119        FETCH_DIM_R                                      ~104    !8, !15
        120        ASSIGN_OP                                     1          !17, ~104
   60   121        FETCH_DIM_R                                      ~107    !8, !15
        122        ASSIGN_DIM_OP                +=               1          !19, !15
        123        OP_DATA                                                  ~107
   61   124        PRE_INC                                                  !18
   44   125      > JMP                                                      ->71
        126    >   FE_FREE                                                  $64
   64   127      > JMPZ                                                     !5, ->134
        128    >   CONCAT                                           ~109    '%3Ctd+class%3D%22tot1%22%3E', !17
        129        CONCAT                                           ~110    ~109, '%3C%2Ftd%3E'
        130        ASSIGN_OP                                     8          !13, ~110
   66   131        FETCH_DIM_W                                      $112    !14, !16
        132        ASSIGN_DIM                                               $112
        133        OP_DATA                                                  !17
   68   134    >   ASSIGN_OP                                     8          !13, '%3C%2Ftr%3E'
   69   135        PRE_INC                                                  !16
   38   136      > JMP                                                      ->59
        137    >   FE_FREE                                                  $53
   72   138        ASSIGN_OP                                     8          !13, '%3Ctr%3E'
   73   139        ASSIGN_OP                                     8          !13, '%3Ctd++class%3D%22tot1%22%3ETOTALE%3C%2Ftd%3E'
   74   140        FETCH_DIM_W                                      $118    !14, !16
        141        ASSIGN_DIM                                               $118
        142        OP_DATA                                                  'TOTALE'
   75   143      > FE_RESET_R                                       $120    !19, ->153
        144    > > FE_FETCH_R                                               $120, !20, ->153
   76   145    >   CONCAT                                           ~121    '%3Ctd++class%3D%22tot1%22%3E', !20
        146        CONCAT                                           ~122    ~121, '%3C%2Ftd%3E'
        147        ASSIGN_OP                                     8          !13, ~122
   77   148        FETCH_DIM_W                                      $124    !14, !16
        149        ASSIGN_DIM                                               $124
        150        OP_DATA                                                  !20
   78   151        ASSIGN_OP                                     1          !21, !20
   75   152      > JMP                                                      ->144
        153    >   FE_FREE                                                  $120
   80   154      > JMPZ                                                     !5, ->161
   81   155    >   CONCAT                                           ~127    '%3Ctd++class%3D%22totfinal%22%3E', !21
        156        CONCAT                                           ~128    ~127, '%3C%2Ftd%3E'
        157        ASSIGN_OP                                     8          !13, ~128
   82   158        FETCH_DIM_W                                      $130    !14, !16
        159        ASSIGN_DIM                                               $130
        160        OP_DATA                                                  !21
   84   161    >   ASSIGN_OP                                     8          !13, '%3C%2Ftr%3E'
   85   162        ASSIGN_OP                                     8          !13, '%3C%2Ftable%3E'
   87   163      > JMPZ                                                     !3, ->166
        164    > > RETURN                                                   !14
        165*       JMP                                                      ->167
   88   166    > > RETURN                                                   !13
   89   167*     > RETURN                                                   null

End of function tabella_riassunto

End of class tableutils.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.12 ms | 1416 KiB | 19 Q