3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( 0 => array('title'=>'a', 'start_date'=>'2013/04/20', 'end_date'=>'2013/05/20'), 1 => array('title'=>'a', 'start_date'=>'2013/04/20', 'end_date'=>'2013/05/20'), 2 => array('title'=>'a', 'start_date'=>'2013/04/20', 'end_date'=>'2013/05/20'), 3 => array('title'=>'b', 'start_date'=>'2013/04/20', 'end_date'=>'2013/05/20'), 4 => array('title'=>'c', 'start_date'=>'2013/04/20', 'end_date'=>'2013/05/20'), 5 => array('title'=>'c', 'start_date'=>'2013/04/20', 'end_date'=>'2013/05/20'), ); // manipulate by array $data2 = array_group($data, 'title'); function array_group($input,$sortkey){ foreach ($input as $key=>$val) { $output[$val[$sortkey]][]=$val; } return $output; } ?> <!-- Asal --> <h1>Old</h1> <table class="table" border="1"> <tr> <td>Title</td> <td>Start Date</td> <td>End Date</td> </tr> <?php foreach($data as $k=>$v) { ?> <tr> <td><?php echo $v['title'] ?></td> <td><?php echo $v['start_date'] ?></td> <td><?php echo $v['end_date']?></td> </tr> <?php } ?> </table> <!-- Lepas dah manipulate --> <h1>Latest</h1> <table border="1"> <tr> <td>Title</td> <td>Start date</td> <td>End date</td> </tr> <?php foreach ($data2 as $key => $value): $rowspan=count($value); ?> <tr> <td rowspan="<?php echo $rowspan; ?>"><?php echo $key;?></td> <td><?php echo $value[0]['start_date']?></td> <td><?php echo $value[0]['end_date']?></td> </tr> <?php $i=1;while($i<$rowspan) { ?> <tr> <td><?php echo $value[$i]['start_date']?></td> <td><?php echo $value[$i]['end_date']?></td> </tr> <?php $i++;} ?> <?php endforeach ?> </table>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 21
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 21
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 57
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 57
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 43
Branch analysis from position: 55
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 43
Branch analysis from position: 55
Branch analysis from position: 43
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
Branch analysis from position: 21
filename:       /in/dmXs0
function name:  (null)
number of ops:  60
compiled vars:  !0 = $data, !1 = $data2, !2 = $v, !3 = $k, !4 = $value, !5 = $key, !6 = $rowspan, !7 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL_BY_NAME                                       'array_group'
          2        SEND_VAR_EX                                              !0
          3        SEND_VAL_EX                                              'title'
          4        DO_FCALL                                      0  $9      
          5        ASSIGN                                                   !1, $9
   26     6        ECHO                                                     '+++++%0A++++%3C%21--+Asal+--%3E%0A++++%3Ch1%3EOld%3C%2Fh1%3E%0A++++%3Ctable+class%3D%22table%22+border%3D%221%22%3E%0A++++++++++++%3Ctr%3E%0A++++++++++++++++++++%3Ctd%3ETitle%3C%2Ftd%3E%0A++++++++++++++++++++%3Ctd%3EStart+Date%3C%2Ftd%3E%0A++++++++++++++++++++%3Ctd%3EEnd+Date%3C%2Ftd%3E%0A++++++++++++%3C%2Ftr%3E%0A++++++++++++'
   35     7      > FE_RESET_R                                       $11     !0, ->21
          8    > > FE_FETCH_R                                       ~12     $11, !2, ->21
          9    >   ASSIGN                                                   !3, ~12
   36    10        ECHO                                                     '++++++++++++++++++++%3Ctr%3E%0A++++++++++++++++++++++++++++%3Ctd%3E'
   37    11        FETCH_DIM_R                                      ~14     !2, 'title'
         12        ECHO                                                     ~14
         13        ECHO                                                     '%3C%2Ftd%3E%0A++++++++++++++++++++++++++++%3Ctd%3E'
   38    14        FETCH_DIM_R                                      ~15     !2, 'start_date'
         15        ECHO                                                     ~15
         16        ECHO                                                     '%3C%2Ftd%3E%0A++++++++++++++++++++++++++++%3Ctd%3E'
   39    17        FETCH_DIM_R                                      ~16     !2, 'end_date'
         18        ECHO                                                     ~16
         19        ECHO                                                     '%3C%2Ftd%3E%0A++++++++++++++++++++%3C%2Ftr%3E%0A++++++++++++'
   35    20      > JMP                                                      ->8
         21    >   FE_FREE                                                  $11
   42    22        ECHO                                                     '++++%3C%2Ftable%3E%0A+++++%0A++++%3C%21--+Lepas+dah+manipulate+--%3E%0A++++%3Ch1%3ELatest%3C%2Fh1%3E%0A++++%3Ctable+border%3D%221%22%3E%0A++++++++++++%3Ctr%3E%0A++++++++++++++++++++%3Ctd%3ETitle%3C%2Ftd%3E%0A++++++++++++++++++++%3Ctd%3EStart+date%3C%2Ftd%3E%0A++++++++++++++++++++%3Ctd%3EEnd+date%3C%2Ftd%3E%0A++++++++++++%3C%2Ftr%3E%0A++++++++++++'
   52    23      > FE_RESET_R                                       $17     !1, ->57
         24    > > FE_FETCH_R                                       ~18     $17, !4, ->57
         25    >   ASSIGN                                                   !5, ~18
   53    26        COUNT                                            ~20     !4
         27        ASSIGN                                                   !6, ~20
   55    28        ECHO                                                     '++++++++++++++++++++%3Ctr%3E%0A++++++++++++++++++++++++++++%3Ctd+rowspan%3D%22'
   56    29        ECHO                                                     !6
         30        ECHO                                                     '%22%3E'
         31        ECHO                                                     !5
         32        ECHO                                                     '%3C%2Ftd%3E%0A++++++++++++++++++++++++++++%3Ctd%3E'
   57    33        FETCH_DIM_R                                      ~22     !4, 0
         34        FETCH_DIM_R                                      ~23     ~22, 'start_date'
         35        ECHO                                                     ~23
         36        ECHO                                                     '%3C%2Ftd%3E%0A++++++++++++++++++++++++++++%3Ctd%3E'
   58    37        FETCH_DIM_R                                      ~24     !4, 0
         38        FETCH_DIM_R                                      ~25     ~24, 'end_date'
         39        ECHO                                                     ~25
         40        ECHO                                                     '%3C%2Ftd%3E%0A++++++++++++++++++++%3C%2Ftr%3E%0A++++++++++++++++++++'
   60    41        ASSIGN                                                   !7, 1
         42      > JMP                                                      ->53
   61    43    >   ECHO                                                     '++++++++++++++++++++%3Ctr%3E%0A++++++++++++++++++++++++++++%3Ctd%3E'
   62    44        FETCH_DIM_R                                      ~27     !4, !7
         45        FETCH_DIM_R                                      ~28     ~27, 'start_date'
         46        ECHO                                                     ~28
         47        ECHO                                                     '%3C%2Ftd%3E%0A++++++++++++++++++++++++++++%3Ctd%3E'
   63    48        FETCH_DIM_R                                      ~29     !4, !7
         49        FETCH_DIM_R                                      ~30     ~29, 'end_date'
         50        ECHO                                                     ~30
         51        ECHO                                                     '%3C%2Ftd%3E%0A++++++++++++++++++++%3C%2Ftr%3E%0A++++++++++++++++++++'
   65    52        PRE_INC                                                  !7
   60    53    >   IS_SMALLER                                               !7, !6
         54      > JMPNZ                                                    ~32, ->43
   66    55    >   ECHO                                                     '++++++++++++'
   52    56      > JMP                                                      ->24
         57    >   FE_FREE                                                  $17
   67    58        ECHO                                                     '++++%3C%2Ftable%3E'
         59      > RETURN                                                   1

Function array_group:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/dmXs0
function name:  array_group
number of ops:  13
compiled vars:  !0 = $input, !1 = $sortkey, !2 = $val, !3 = $key, !4 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2      > FE_RESET_R                                       $5      !0, ->10
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->10
          4    >   ASSIGN                                                   !3, ~6
   19     5        FETCH_DIM_R                                      ~8      !2, !1
          6        FETCH_DIM_W                                      $9      !4, ~8
          7        ASSIGN_DIM                                               $9
          8        OP_DATA                                                  !2
   17     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $5
   22    11      > RETURN                                                   !4
   23    12*     > RETURN                                                   null

End of function array_group

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.18 ms | 1403 KiB | 13 Q