3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '2018-10-03' => 5, '2018-10-06' => 5, '2018-10-09' => 5, '2018-10-03' => 4, ]; $rotate = []; foreach ($array as $date => $value) { $rotate[$value][] = $date; } $group = []; foreach ($rotate as $value => $dates) { $group[] = [ 'start' => min($dates), 'end' => max($dates), 'value' => $value ]; } var_dump($rotate); var_dump($group);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 26
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 9
filename:       /in/N6E6D
function name:  (null)
number of ops:  34
compiled vars:  !0 = $array, !1 = $rotate, !2 = $value, !3 = $date, !4 = $group, !5 = $dates
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   11     2      > FE_RESET_R                                       $8      !0, ->9
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->9
          4    >   ASSIGN                                                   !3, ~9
   12     5        FETCH_DIM_W                                      $11     !1, !2
          6        ASSIGN_DIM                                               $11
          7        OP_DATA                                                  !3
   11     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $8
   14    10        ASSIGN                                                   !4, <array>
   15    11      > FE_RESET_R                                       $14     !1, ->26
         12    > > FE_FETCH_R                                       ~15     $14, !5, ->26
         13    >   ASSIGN                                                   !2, ~15
   16    14        INIT_FCALL                                               'min'
         15        SEND_VAR                                                 !5
         16        DO_ICALL                                         $18     
         17        INIT_ARRAY                                       ~19     $18, 'start'
         18        INIT_FCALL                                               'max'
         19        SEND_VAR                                                 !5
         20        DO_ICALL                                         $20     
         21        ADD_ARRAY_ELEMENT                                ~19     $20, 'end'
         22        ADD_ARRAY_ELEMENT                                ~19     !2, 'value'
         23        ASSIGN_DIM                                               !4
         24        OP_DATA                                                  ~19
   15    25      > JMP                                                      ->12
         26    >   FE_FREE                                                  $14
   19    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                                 
   20    30        INIT_FCALL                                               'var_dump'
         31        SEND_VAR                                                 !4
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.12 ms | 1001 KiB | 16 Q