3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( 0 => Array ( 'date' => '2017-08-22', 'AAA' => '1231', ), 1 => Array ( 'date' => '2017-08-21', 'AAA' => '1172', ), 2 => Array ( 'date' => '2017-08-20', 'AAA' => '1125' ), 3 => Array ( 'date' => '2017-08-21', 'BBB' => '251' ), 4 => Array ( 'date' => '2017-08-20', 'BBB' => '21773', ), 5 => Array ( 'date' => '2017-08-22', 'CCC' => '3750' ), 6 => Array ( 'date' => '2017-08-20', 'CCC' => '321750' ) ); echo '<pre>'; $array1 = array('AAA' => null, 'BBB' => null, 'CCC' => null); $array2 = array(); array_walk($array, function ($v) use (&$array2, $array1) { $a = $v['date']; if (!isset($array2[$a])) { $array2[$a] = $array1; } unset($v['date']); $array2[$a] = array_merge($array2[$a], $v); }); print_r($array2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NvLB8
function name:  (null)
number of ops:  15
compiled vars:  !0 = $array, !1 = $array1, !2 = $array2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   40     1        ECHO                                                     '%3Cpre%3E'
   41     2        ASSIGN                                                   !1, <array>
   42     3        ASSIGN                                                   !2, <array>
   44     4        INIT_FCALL                                               'array_walk'
          5        SEND_REF                                                 !0
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNvLB8%3A44%240'
          7        BIND_LEXICAL                                             ~6, !2
          8        BIND_LEXICAL                                             ~6, !1
   51     9        SEND_VAL                                                 ~6
         10        DO_ICALL                                                 
   53    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FNvLB8%3A44%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/NvLB8
function name:  {closure}
number of ops:  19
compiled vars:  !0 = $v, !1 = $array2, !2 = $array1, !3 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
   45     3        FETCH_DIM_R                                      ~4      !0, 'date'
          4        ASSIGN                                                   !3, ~4
   46     5        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !1, !3
          6        BOOL_NOT                                         ~7      ~6
          7      > JMPZ                                                     ~7, ->10
   47     8    >   ASSIGN_DIM                                               !1, !3
          9        OP_DATA                                                  !2
   49    10    >   UNSET_DIM                                                !0, 'date'
   50    11        INIT_FCALL                                               'array_merge'
         12        FETCH_DIM_R                                      ~10     !1, !3
         13        SEND_VAL                                                 ~10
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $11     
         16        ASSIGN_DIM                                               !1, !3
         17        OP_DATA                                                  $11
   51    18      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FNvLB8%3A44%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.46 ms | 1396 KiB | 19 Q