3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( '0' => Array ( 'NDC_Date' => '2017-03-27', 'NDC_Item' => '0', 'NDC_Type' => 'Night', 'NDC_Rate' => '12.00', 'NDC_Taxes' => '0', 'NDC_TaxesName' => '0', 'NDC_Quantity' => '1', 'NDC_Status' => 'NotCharged', ), '1' => Array ( 'NDC_Date' => '2017-03-28', 'NDC_Item' => '0', 'NDC_Type' => 'Night', 'NDC_Rate' => '12.00', 'NDC_Taxes' => '0', 'NDC_TaxesName' => '0', 'NDC_Quantity' => '1', 'NDC_Status' => 'NotCharged', ), '2' => Array ( 'NDC_Date' => '2017-03-29', 'NDC_Item' => '0', 'NDC_Type' => 'Test', 'NDC_Rate' => '12.00', 'NDC_Taxes' => '0', 'NDC_TaxesName' => '0', 'NDC_Quantity' => '1', 'NDC_Status' => 'NotCharged', ), '3' => Array ( 'NDC_Date' => '2017-03-30', 'NDC_Item' => '0', 'NDC_Type' => 'Test', 'NDC_Rate' => '12.00', 'NDC_Taxes' => '0', 'NDC_TaxesName' => '0', 'NDC_Quantity' => '1', 'NDC_Status' => 'NotCharged', ), '4' => Array ( 'NDC_Date' => '2017-03-31', 'NDC_Item' => '0', 'NDC_Type' => 'Night', 'NDC_Rate' => '12.00', 'NDC_Taxes' => '0', 'NDC_TaxesName' => '0', 'NDC_Quantity' => '1', 'NDC_Status' => 'NotCharged', ), '5' => Array ( 'NDC_Date' => '2017-04-01', 'NDC_Item' => '0', 'NDC_Type' => 'Night', 'NDC_Rate' => '12.00', 'NDC_Taxes' => '0', 'NDC_TaxesName' => '0', 'NDC_Quantity' => '1', 'NDC_Status' => 'NotCharged', ), '6' => Array ( 'NDC_Date' => '2017-04-02', 'NDC_Item' => '0', 'NDC_Type' => 'Night', 'NDC_Rate' => '12.00', 'NDC_Taxes' => '0', 'NDC_TaxesName' => '0', 'NDC_Quantity' => '1', 'NDC_Status' => 'NotCharged', ), '7' => Array ( 'NDC_Date' => '2017-04-03', 'NDC_Item' => '0', 'NDC_Type' => 'Night', 'NDC_Rate' => '12.00', 'NDC_Taxes' => '0', 'NDC_TaxesName' => '0', 'NDC_Quantity' => '1', 'NDC_Status' => 'NotCharged', ), ); foreach ($array as $item) { $k = $item['NDC_Type']; if (!isset($result[$k])) { $result[$k] = $item; } elseif ( ($i = $result[$k]) && $item['NDC_Rate'] === $i['NDC_Rate'] && $item['NDC_Item'] === $i['NDC_Item'] && $item['NDC_Taxes'] === $i['NDC_Taxes'] && $item['NDC_TaxesName'] === $i['NDC_TaxesName'] && $item['NDC_Quantity'] === $i['NDC_Quantity'] && $item['NDC_Status']=== $i['NDC_Status'] ) { $current_dates = explode(',', $result[$k]['NDC_Date']); $last_date = end($current_dates); if(date('Y-m-d', strtotime("{$last_date} +1 day")) === $item['NDC_Date']) { $result[$k]['NDC_Date'] .= ','. $item['NDC_Date']; } else { $result[$k. microtime()] = $item; } } else { $result[$k. microtime()] = $item; } } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 85
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 85
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 38
Branch analysis from position: 34
2 jumps found. (Code = 46) Position 1 = 39, Position 2 = 43
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 79
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 73
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 78
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 84
Branch analysis from position: 84
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 43
Branch analysis from position: 38
Branch analysis from position: 33
Branch analysis from position: 28
Branch analysis from position: 23
Branch analysis from position: 18
Branch analysis from position: 85
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 85
filename:       /in/UGhIW
function name:  (null)
number of ops:  90
compiled vars:  !0 = $array, !1 = $item, !2 = $k, !3 = $result, !4 = $i, !5 = $current_dates, !6 = $last_date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   85     1      > FE_RESET_R                                       $8      !0, ->85
          2    > > FE_FETCH_R                                               $8, !1, ->85
   86     3    >   FETCH_DIM_R                                      ~9      !1, 'NDC_Type'
          4        ASSIGN                                                   !2, ~9
   88     5        ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !3, !2
          6        BOOL_NOT                                         ~12     ~11
          7      > JMPZ                                                     ~12, ->11
   89     8    >   ASSIGN_DIM                                               !3, !2
          9        OP_DATA                                                  !1
         10      > JMP                                                      ->84
   91    11    >   FETCH_DIM_R                                      ~14     !3, !2
         12        ASSIGN                                           ~15     !4, ~14
         13      > JMPZ_EX                                          ~15     ~15, ->18
   92    14    >   FETCH_DIM_R                                      ~16     !1, 'NDC_Rate'
         15        FETCH_DIM_R                                      ~17     !4, 'NDC_Rate'
         16        IS_IDENTICAL                                     ~18     ~16, ~17
         17        BOOL                                             ~15     ~18
         18    > > JMPZ_EX                                          ~15     ~15, ->23
   93    19    >   FETCH_DIM_R                                      ~19     !1, 'NDC_Item'
         20        FETCH_DIM_R                                      ~20     !4, 'NDC_Item'
         21        IS_IDENTICAL                                     ~21     ~19, ~20
         22        BOOL                                             ~15     ~21
         23    > > JMPZ_EX                                          ~15     ~15, ->28
   94    24    >   FETCH_DIM_R                                      ~22     !1, 'NDC_Taxes'
         25        FETCH_DIM_R                                      ~23     !4, 'NDC_Taxes'
         26        IS_IDENTICAL                                     ~24     ~22, ~23
         27        BOOL                                             ~15     ~24
         28    > > JMPZ_EX                                          ~15     ~15, ->33
   95    29    >   FETCH_DIM_R                                      ~25     !1, 'NDC_TaxesName'
         30        FETCH_DIM_R                                      ~26     !4, 'NDC_TaxesName'
         31        IS_IDENTICAL                                     ~27     ~25, ~26
         32        BOOL                                             ~15     ~27
         33    > > JMPZ_EX                                          ~15     ~15, ->38
   96    34    >   FETCH_DIM_R                                      ~28     !1, 'NDC_Quantity'
         35        FETCH_DIM_R                                      ~29     !4, 'NDC_Quantity'
         36        IS_IDENTICAL                                     ~30     ~28, ~29
         37        BOOL                                             ~15     ~30
         38    > > JMPZ_EX                                          ~15     ~15, ->43
   97    39    >   FETCH_DIM_R                                      ~31     !1, 'NDC_Status'
         40        FETCH_DIM_R                                      ~32     !4, 'NDC_Status'
         41        IS_IDENTICAL                                     ~33     ~31, ~32
         42        BOOL                                             ~15     ~33
         43    > > JMPZ                                                     ~15, ->79
   99    44    >   INIT_FCALL                                               'explode'
         45        SEND_VAL                                                 '%2C'
         46        FETCH_DIM_R                                      ~34     !3, !2
         47        FETCH_DIM_R                                      ~35     ~34, 'NDC_Date'
         48        SEND_VAL                                                 ~35
         49        DO_ICALL                                         $36     
         50        ASSIGN                                                   !5, $36
  100    51        INIT_FCALL                                               'end'
         52        SEND_REF                                                 !5
         53        DO_ICALL                                         $38     
         54        ASSIGN                                                   !6, $38
  101    55        INIT_FCALL                                               'date'
         56        SEND_VAL                                                 'Y-m-d'
         57        INIT_FCALL                                               'strtotime'
         58        NOP                                                      
         59        FAST_CONCAT                                      ~40     !6, '+%2B1+day'
         60        SEND_VAL                                                 ~40
         61        DO_ICALL                                         $41     
         62        SEND_VAR                                                 $41
         63        DO_ICALL                                         $42     
         64        FETCH_DIM_R                                      ~43     !1, 'NDC_Date'
         65        IS_IDENTICAL                                             $42, ~43
         66      > JMPZ                                                     ~44, ->73
  102    67    >   FETCH_DIM_R                                      ~47     !1, 'NDC_Date'
         68        CONCAT                                           ~48     '%2C', ~47
         69        FETCH_DIM_RW                                     $45     !3, !2
         70        ASSIGN_DIM_OP                .=               8          $45, 'NDC_Date'
         71        OP_DATA                                                  ~48
         72      > JMP                                                      ->78
  104    73    >   INIT_FCALL                                               'microtime'
         74        DO_ICALL                                         $49     
         75        CONCAT                                           ~50     !2, $49
         76        ASSIGN_DIM                                               !3, ~50
         77        OP_DATA                                                  !1
         78    > > JMP                                                      ->84
  107    79    >   INIT_FCALL                                               'microtime'
         80        DO_ICALL                                         $52     
         81        CONCAT                                           ~53     !2, $52
         82        ASSIGN_DIM                                               !3, ~53
         83        OP_DATA                                                  !1
   85    84    > > JMP                                                      ->2
         85    >   FE_FREE                                                  $8
  111    86        INIT_FCALL                                               'print_r'
         87        SEND_VAR                                                 !3
         88        DO_ICALL                                                 
         89      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.8 ms | 1404 KiB | 25 Q