3v4l.org

run code in 300+ PHP versions simultaneously
<?php $season_data = [ 'Paul' => [ 'Season' => [2014, 2015, 2016] ], 'John' => [ 'Season' => [2012] ] ]; $appearance_data = [ 'Paul' => [ 'Appearance'=> [ 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2015, 2015, 2015 ] ], 'John' => [ 'Appearance' => [ 2012, 2012, 2012, 2012 ] ] ]; foreach ($season_data as $person => $data) { foreach ($data['Season'] as $year) { $result[$person]['SeasonCounts'][$year] = sizeof(array_filter( $appearance_data[$person]['Appearance'], function($v) use ($year) { return $v == $year; })); } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 22
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 22
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/XeEbT
function name:  (null)
number of ops:  29
compiled vars:  !0 = $season_data, !1 = $appearance_data, !2 = $data, !3 = $person, !4 = $year, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   24     2      > FE_RESET_R                                       $8      !0, ->24
          3    > > FE_FETCH_R                                       ~9      $8, !2, ->24
          4    >   ASSIGN                                                   !3, ~9
   25     5        FETCH_DIM_R                                      ~11     !2, 'Season'
          6      > FE_RESET_R                                       $12     ~11, ->22
          7    > > FE_FETCH_R                                               $12, !4, ->22
   26     8    >   INIT_FCALL                                               'array_filter'
   27     9        FETCH_DIM_R                                      ~16     !1, !3
         10        FETCH_DIM_R                                      ~17     ~16, 'Appearance'
         11        SEND_VAL                                                 ~17
   28    12        DECLARE_LAMBDA_FUNCTION                          ~18     [0]
         13        BIND_LEXICAL                                             ~18, !4
   30    14        SEND_VAL                                                 ~18
   26    15        DO_ICALL                                         $19     
   30    16        COUNT                                            ~20     $19
   26    17        FETCH_DIM_W                                      $13     !5, !3
         18        FETCH_DIM_W                                      $14     $13, 'SeasonCounts'
         19        ASSIGN_DIM                                               $14, !4
   30    20        OP_DATA                                                  ~20
   25    21      > JMP                                                      ->7
         22    >   FE_FREE                                                  $12
   24    23      > JMP                                                      ->3
         24    >   FE_FREE                                                  $8
   33    25        INIT_FCALL                                               'var_export'
         26        SEND_VAR                                                 !5
         27        DO_ICALL                                                 
         28      > 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/XeEbT
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $v, !1 = $year
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   29     2        IS_EQUAL                                         ~2      !0, !1
          3      > RETURN                                                   ~2
   30     4*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.39 ms | 1004 KiB | 15 Q