3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = Array( Array ( 'C1', 'C1', 'C1', 'AC', 'AC' ) ); $arr2 = Array( Array( 'C1_complete', 'C1_29-95', 'C1_49-95', 'AC_complete', 'AC_29-95' ) ); $data = array_combine(array_values($arr1[0]),array_fill(0,count($arr1[0]),[])); array_walk($arr2[0],function($value) use (&$data){ if(isset($data[explode("_",$value)[0]])) $data[explode("_",$value)[0]][] = $value; }); $data = [$data]; // since you want it inside another array. print_r($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VhFLH7
function name:  (null)
number of ops:  31
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, <array>
   25     2        INIT_FCALL                                               'array_combine'
          3        INIT_FCALL                                               'array_values'
          4        FETCH_DIM_R                                      ~5      !0, 0
          5        SEND_VAL                                                 ~5
          6        DO_ICALL                                         $6      
          7        SEND_VAR                                                 $6
          8        INIT_FCALL                                               'array_fill'
          9        SEND_VAL                                                 0
         10        FETCH_DIM_R                                      ~7      !0, 0
         11        COUNT                                            ~8      ~7
         12        SEND_VAL                                                 ~8
         13        SEND_VAL                                                 <array>
         14        DO_ICALL                                         $9      
         15        SEND_VAR                                                 $9
         16        DO_ICALL                                         $10     
         17        ASSIGN                                                   !2, $10
   27    18        INIT_FCALL                                               'array_walk'
         19        FETCH_DIM_W                                      $12     !1, 0
         20        SEND_REF                                                 $12
         21        DECLARE_LAMBDA_FUNCTION                          ~13     [0]
         22        BIND_LEXICAL                                             ~13, !2
   29    23        SEND_VAL                                                 ~13
   27    24        DO_ICALL                                                 
   31    25        INIT_ARRAY                                       ~15     !2
         26        ASSIGN                                                   !2, ~15
   33    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
         30      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/VhFLH7
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $value, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   28     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '_'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $2      
          6        FETCH_DIM_R                                      ~3      $2, 0
          7        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~3
          8      > JMPZ                                                     ~4, ->17
          9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '_'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        FETCH_DIM_R                                      ~6      $5, 0
         14        FETCH_DIM_W                                      $7      !1, ~6
         15        ASSIGN_DIM                                               $7
         16        OP_DATA                                                  !0
   29    17    > > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.07 ms | 1021 KiB | 19 Q