3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [ 1 => [ "opens_at" => "10:00", "closes_at" => "18:00" ], 2 => [ "opens_at" => "10:00", "closes_at" => "18:00" ], 3 => [ "opens_at" => "10:00", "closes_at" => "18:00" ], 4 => [ "opens_at" => "14:00", "closes_at" => "17:00" ], 5 => [ "opens_at" => "14:00", "closes_at" => "17:00" ], 6 => [ "opens_at" => "18:00", "closes_at" => "19:00" ] ]; $groups = []; foreach($a as $dayNumber => $w){ if(!array_key_exists($w['opens_at'] . '-' . $w['closes_at'], $groups)){ $groups[$w['opens_at'] . '-' . $w['closes_at']] = []; } $groups[$w['opens_at'] . '-' . $w['closes_at']][] = $dayNumber; } $res = array_map(function($v){ return implode(', ', $v); }, $groups); var_dump(array_flip($res));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 26
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/p4oa6
function name:  (null)
number of ops:  40
compiled vars:  !0 = $a, !1 = $groups, !2 = $w, !3 = $dayNumber, !4 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   30     1        ASSIGN                                                   !1, <array>
   32     2      > FE_RESET_R                                       $7      !0, ->26
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->26
          4    >   ASSIGN                                                   !3, ~8
   33     5        FETCH_DIM_R                                      ~10     !2, 'opens_at'
          6        CONCAT                                           ~11     ~10, '-'
          7        FETCH_DIM_R                                      ~12     !2, 'closes_at'
          8        CONCAT                                           ~13     ~11, ~12
          9        ARRAY_KEY_EXISTS                                 ~14     ~13, !1
         10        BOOL_NOT                                         ~15     ~14
         11      > JMPZ                                                     ~15, ->18
   34    12    >   FETCH_DIM_R                                      ~16     !2, 'opens_at'
         13        CONCAT                                           ~17     ~16, '-'
         14        FETCH_DIM_R                                      ~18     !2, 'closes_at'
         15        CONCAT                                           ~19     ~17, ~18
         16        ASSIGN_DIM                                               !1, ~19
         17        OP_DATA                                                  <array>
   37    18    >   FETCH_DIM_R                                      ~21     !2, 'opens_at'
         19        CONCAT                                           ~22     ~21, '-'
         20        FETCH_DIM_R                                      ~23     !2, 'closes_at'
         21        CONCAT                                           ~24     ~22, ~23
         22        FETCH_DIM_W                                      $25     !1, ~24
         23        ASSIGN_DIM                                               $25
         24        OP_DATA                                                  !3
   32    25      > JMP                                                      ->3
         26    >   FE_FREE                                                  $7
   40    27        INIT_FCALL                                               'array_map'
         28        DECLARE_LAMBDA_FUNCTION                          ~27     [0]
   42    29        SEND_VAL                                                 ~27
         30        SEND_VAR                                                 !1
   40    31        DO_ICALL                                         $28     
         32        ASSIGN                                                   !4, $28
   44    33        INIT_FCALL                                               'var_dump'
         34        INIT_FCALL                                               'array_flip'
         35        SEND_VAR                                                 !4
         36        DO_ICALL                                         $30     
         37        SEND_VAR                                                 $30
         38        DO_ICALL                                                 
         39      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p4oa6
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
   41     1        INIT_FCALL                                               'implode'
          2        SEND_VAL                                                 '%2C+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   42     6*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.29 ms | 1018 KiB | 17 Q