3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '2017-05-01' => [ 'DC' => [ 'IT' => [90, 0], 'DE' => [18, 315, 40, '', 69, 211], 'Other' => [107, 46, '', '', 27, 22] ] ], '2017-05-02' => [ 'DC' => [ 'IT' => [70, 40, 55], 'DE' => ['', 31, 4, '', 9], 'Other' => [1107, 12, 0, 20, 1, 11, 21] ] ], 'fringe case' => [ 'DC' => [ 'IT' => [], 'DE' => ['', '', '', 99], 'Other' => ['', 99] ] ] ]; array_walk( $array, fn(&$dateSet) => array_walk( $dateSet, fn(&$dcSet) => array_walk( $dcSet, function (&$set) { if (!$set) { $set = 0; return; } sort($set); $count = count($set); $mid = intdiv($count, 2); if ($count & 1) { $set = $set[$mid]; return; } $set = ((int)$set[$mid - 1] + (int)$set[$mid]) / 2; } ) ) ); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PTLjb
function name:  (null)
number of ops:  11
compiled vars:  !0 = $array, !1 = $dcSet
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   26     1        INIT_FCALL                                               'array_walk'
   27     2        SEND_REF                                                 !0
   28     3        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          4        BIND_LEXICAL                                             ~3, !1
   48     5        SEND_VAL                                                 ~3
   26     6        DO_ICALL                                                 
   49     7        INIT_FCALL                                               'var_export'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
         10      > 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/PTLjb
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $dateSet, !1 = $dcSet
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'array_walk'
   29     3        SEND_REF                                                 !0
   30     4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   47     5        SEND_VAL                                                 ~2
   28     6        DO_ICALL                                         $3      
   47     7      > RETURN                                                   $3
   48     8*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PTLjb
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $dcSet
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'array_walk'
   31     2        SEND_REF                                                 !0
   32     3        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
   45     4        SEND_VAL                                                 ~1
   30     5        DO_ICALL                                         $2      
   45     6      > RETURN                                                   $2
   47     7*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PTLjb
function name:  {closure}
number of ops:  29
compiled vars:  !0 = $set, !1 = $count, !2 = $mid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   33     1        BOOL_NOT                                         ~3      !0
          2      > JMPZ                                                     ~3, ->5
   34     3    >   ASSIGN                                                   !0, 0
   35     4      > RETURN                                                   null
   37     5    >   INIT_FCALL                                               'sort'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                                 
   38     8        COUNT                                            ~6      !0
          9        ASSIGN                                                   !1, ~6
   39    10        INIT_FCALL                                               'intdiv'
         11        SEND_VAR                                                 !1
         12        SEND_VAL                                                 2
         13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !2, $8
   40    15        BW_AND                                           ~10     !1, 1
         16      > JMPZ                                                     ~10, ->20
   41    17    >   FETCH_DIM_R                                      ~11     !0, !2
         18        ASSIGN                                                   !0, ~11
   42    19      > RETURN                                                   null
   44    20    >   SUB                                              ~13     !2, 1
         21        FETCH_DIM_R                                      ~14     !0, ~13
         22        CAST                                          4  ~15     ~14
         23        FETCH_DIM_R                                      ~16     !0, !2
         24        CAST                                          4  ~17     ~16
         25        ADD                                              ~18     ~15, ~17
         26        DIV                                              ~19     ~18, 2
         27        ASSIGN                                                   !0, ~19
   45    28      > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.83 ms | 1013 KiB | 17 Q