3v4l.org

run code in 300+ PHP versions simultaneously
<?php $movies = [ 'MOVIE TITLE #1' => [ 'id' => 11990, 'times' => [ '2023-06-03' => [ '11:00am', '2:30pm', '6:00pm', '9:30pm', ], '2023-06-04' => [ '12:30pm', '4:00pm', '7:30pm', ], '2023-06-06' => [ '12:30pm', '4:00pm', '7:30pm', ], ], ], 'MOVIE TITLE #2' => [ 'id' => 11892, 'times' => [ '2023-06-03' => [ '12:00pm', '3:30pm', '7:00pm', ], ], ], ]; $dates = array_flip(['2023-06-03', '2023-06-04']); $result = []; foreach ($movies as $title => ['times' => $times]) { foreach (array_intersect_key($times, $dates) as $date => $times) { $result[$date][$title] = $times; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 25
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 23
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/cQNXv
function name:  (null)
number of ops:  30
compiled vars:  !0 = $movies, !1 = $dates, !2 = $result, !3 = $times, !4 = $title, !5 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   37     1        INIT_FCALL                                               'array_flip'
          2        SEND_VAL                                                 <array>
          3        DO_ICALL                                         $7      
          4        ASSIGN                                                   !1, $7
   39     5        ASSIGN                                                   !2, <array>
   40     6      > FE_RESET_R                                       $10     !0, ->25
          7    > > FE_FETCH_R                                       ~14     $10, $11, ->25
          8    >   FETCH_LIST_R                                     $12     $11, 'times'
          9        ASSIGN                                                   !3, $12
         10        FREE                                                     $11
         11        ASSIGN                                                   !4, ~14
   41    12        INIT_FCALL                                               'array_intersect_key'
         13        SEND_VAR                                                 !3
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $16     
         16      > FE_RESET_R                                       $17     $16, ->23
         17    > > FE_FETCH_R                                       ~18     $17, !3, ->23
         18    >   ASSIGN                                                   !5, ~18
   42    19        FETCH_DIM_W                                      $20     !2, !5
         20        ASSIGN_DIM                                               $20, !4
         21        OP_DATA                                                  !3
   41    22      > JMP                                                      ->17
         23    >   FE_FREE                                                  $17
   40    24      > JMP                                                      ->7
         25    >   FE_FREE                                                  $10
   45    26        INIT_FCALL                                               'var_export'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.3 ms | 1003 KiB | 16 Q