3v4l.org

run code in 300+ PHP versions simultaneously
<?php $result = array( 'Date 1' => array ( 'Object 1 ' => array ( 'Field 1' => "Value 1", 'Field 2' => "Value 2", 'Field 3' => "Value 3", ), ), 'Date 2' => array ( 'Object 1 in Date 2' => array ( 'Field 1' => "Value 1", 'Field 2' => "Value 2", ), 'Object 2 in Date 2' => array ( 'Field 1' => "Value 1", 'Field 2' => "Value 2", 'Field 3' => "Value 3", ), ), ); function count_childs($parent_array,$total = 0) { if(is_array($parent_array)) { foreach ($parent_array as $key => $value) { if(is_array($value)){ $total += count($value); count_childs($value,$total); } else $total += 1; } } return $total; } $firstField =false; $first = false; echo '<div>'; echo '<table id="r" border=1>'; echo '<tr>'; echo '<th>Date</th>'; echo '<th>Object Type</th>'; echo '<th>Field</th>'; echo '<th>Count</th>'; echo '</tr>'; foreach ($result as $key=>$value){ echo "<tr>"; $date_rowspan = count_childs($value); echo "<td rowspan= $date_rowspan>$key</td>"; foreach ($value as $key1 => $value1) { $obj_rowspan = count_childs($value1); echo "<td rowspan= $obj_rowspan>$key1</td>"; echo $first_row = true; foreach ($value1 as $key2 => $value2) { if($first_row){ echo "<td>$key2</td><td>$value2</td></tr>"; $first_row = false; } else echo "<td>$key2</td><td>$value2</td><tr>"; } } echo "</tr>"; } echo '</table>';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 64
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 64
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 61
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 61
Branch analysis from position: 27
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 59
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 59
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 52
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 59
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 61
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
filename:       /in/SaMXP
function name:  (null)
number of ops:  67
compiled vars:  !0 = $result, !1 = $firstField, !2 = $first, !3 = $value, !4 = $key, !5 = $date_rowspan, !6 = $value1, !7 = $key1, !8 = $obj_rowspan, !9 = $first_row, !10 = $value2, !11 = $key2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   43     1        ASSIGN                                                   !1, <false>
   44     2        ASSIGN                                                   !2, <false>
   45     3        ECHO                                                     '%3Cdiv%3E'
   46     4        ECHO                                                     '%3Ctable+id%3D%22r%22+border%3D1%3E'
   47     5        ECHO                                                     '%3Ctr%3E'
   48     6        ECHO                                                     '%3Cth%3EDate%3C%2Fth%3E'
   49     7        ECHO                                                     '%3Cth%3EObject+Type%3C%2Fth%3E'
   50     8        ECHO                                                     '%3Cth%3EField%3C%2Fth%3E'
   51     9        ECHO                                                     '%3Cth%3ECount%3C%2Fth%3E'
   52    10        ECHO                                                     '%3C%2Ftr%3E'
   53    11      > FE_RESET_R                                       $15     !0, ->64
         12    > > FE_FETCH_R                                       ~16     $15, !3, ->64
         13    >   ASSIGN                                                   !4, ~16
   54    14        ECHO                                                     '%3Ctr%3E'
   56    15        INIT_FCALL                                               'count_childs'
         16        SEND_VAR                                                 !3
         17        DO_FCALL                                      0  $18     
         18        ASSIGN                                                   !5, $18
   57    19        ROPE_INIT                                     5  ~21     '%3Ctd+rowspan%3D+'
         20        ROPE_ADD                                      1  ~21     ~21, !5
         21        ROPE_ADD                                      2  ~21     ~21, '%3E'
         22        ROPE_ADD                                      3  ~21     ~21, !4
         23        ROPE_END                                      4  ~20     ~21, '%3C%2Ftd%3E'
         24        ECHO                                                     ~20
   58    25      > FE_RESET_R                                       $24     !3, ->61
         26    > > FE_FETCH_R                                       ~25     $24, !6, ->61
         27    >   ASSIGN                                                   !7, ~25
   59    28        INIT_FCALL                                               'count_childs'
         29        SEND_VAR                                                 !6
         30        DO_FCALL                                      0  $27     
         31        ASSIGN                                                   !8, $27
   60    32        ROPE_INIT                                     5  ~30     '%3Ctd+rowspan%3D+'
         33        ROPE_ADD                                      1  ~30     ~30, !8
         34        ROPE_ADD                                      2  ~30     ~30, '%3E'
         35        ROPE_ADD                                      3  ~30     ~30, !7
         36        ROPE_END                                      4  ~29     ~30, '%3C%2Ftd%3E'
         37        ECHO                                                     ~29
   61    38        ASSIGN                                           ~33     !9, <true>
         39        ECHO                                                     ~33
   62    40      > FE_RESET_R                                       $34     !6, ->59
         41    > > FE_FETCH_R                                       ~35     $34, !10, ->59
         42    >   ASSIGN                                                   !11, ~35
   63    43      > JMPZ                                                     !9, ->52
   64    44    >   ROPE_INIT                                     5  ~38     '%3Ctd%3E'
         45        ROPE_ADD                                      1  ~38     ~38, !11
         46        ROPE_ADD                                      2  ~38     ~38, '%3C%2Ftd%3E%3Ctd%3E'
         47        ROPE_ADD                                      3  ~38     ~38, !10
         48        ROPE_END                                      4  ~37     ~38, '%3C%2Ftd%3E%3C%2Ftr%3E'
         49        ECHO                                                     ~37
   65    50        ASSIGN                                                   !9, <false>
         51      > JMP                                                      ->58
   68    52    >   ROPE_INIT                                     5  ~43     '%3Ctd%3E'
         53        ROPE_ADD                                      1  ~43     ~43, !11
         54        ROPE_ADD                                      2  ~43     ~43, '%3C%2Ftd%3E%3Ctd%3E'
         55        ROPE_ADD                                      3  ~43     ~43, !10
         56        ROPE_END                                      4  ~42     ~43, '%3C%2Ftd%3E%3Ctr%3E'
         57        ECHO                                                     ~42
   62    58    > > JMP                                                      ->41
         59    >   FE_FREE                                                  $34
   58    60      > JMP                                                      ->26
         61    >   FE_FREE                                                  $24
   72    62        ECHO                                                     '%3C%2Ftr%3E'
   53    63      > JMP                                                      ->12
         64    >   FE_FREE                                                  $15
   74    65        ECHO                                                     '%3C%2Ftable%3E'
         66      > RETURN                                                   1

Function count_childs:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 18
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 19
filename:       /in/SaMXP
function name:  count_childs
number of ops:  21
compiled vars:  !0 = $parent_array, !1 = $total, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
   29     2        TYPE_CHECK                                  128          !0
          3      > JMPZ                                                     ~4, ->19
   31     4    > > FE_RESET_R                                       $5      !0, ->18
          5    > > FE_FETCH_R                                       ~6      $5, !2, ->18
          6    >   ASSIGN                                                   !3, ~6
   32     7        TYPE_CHECK                                  128          !2
          8      > JMPZ                                                     ~8, ->16
   33     9    >   COUNT                                            ~9      !2
         10        ASSIGN_OP                                     1          !1, ~9
   34    11        INIT_FCALL_BY_NAME                                       'count_childs'
         12        SEND_VAR_EX                                              !2
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
         15      > JMP                                                      ->17
   37    16    >   ASSIGN_OP                                     1          !1, 1
   31    17    > > JMP                                                      ->5
         18    >   FE_FREE                                                  $5
   41    19    > > RETURN                                                   !1
   42    20*     > RETURN                                                   null

End of function count_childs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.31 ms | 1407 KiB | 15 Q