3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ [ 'days' => [ 'day_id' => '2016-11-23,2016-11-24', ], ], [ 'days' => [ 'day_id' => '2016-11-25,', ], ], [ 'days' => [ 'day_id' => '', ], ], [ 'days' => [ 'day_id' => '2016-11-27,2016-11-28', ], ], ]; function reduce_func($carry, $item){ if (isset($item['days']) && !empty($item['days']['day_id'])){ $carry += count(array_unique(array_filter(explode(',', $item['days']['day_id'])))); } return $carry; } $result = array_reduce($arr, "reduce_func", 0); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MQ8H0
function name:  (null)
number of ops:  11
compiled vars:  !0 = $arr, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   33     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'reduce_func'
          4        SEND_VAL                                                 0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !1, $3
   34     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function reduce_func:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 23
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 8
filename:       /in/MQ8H0
function name:  reduce_func
number of ops:  25
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   27     2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      !1, 'days'
          3      > JMPZ_EX                                          ~2      ~2, ->8
          4    >   FETCH_DIM_IS                                     ~3      !1, 'days'
          5        ISSET_ISEMPTY_DIM_OBJ                         1  ~4      ~3, 'day_id'
          6        BOOL_NOT                                         ~5      ~4
          7        BOOL                                             ~2      ~5
          8    > > JMPZ                                                     ~2, ->23
   28     9    >   INIT_FCALL                                               'array_unique'
         10        INIT_FCALL                                               'array_filter'
         11        INIT_FCALL                                               'explode'
         12        SEND_VAL                                                 '%2C'
         13        FETCH_DIM_R                                      ~6      !1, 'days'
         14        FETCH_DIM_R                                      ~7      ~6, 'day_id'
         15        SEND_VAL                                                 ~7
         16        DO_ICALL                                         $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                         $9      
         19        SEND_VAR                                                 $9
         20        DO_ICALL                                         $10     
         21        COUNT                                            ~11     $10
         22        ASSIGN_OP                                     1          !0, ~11
   30    23    > > RETURN                                                   !0
   31    24*     > RETURN                                                   null

End of function reduce_func

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.57 ms | 1396 KiB | 23 Q