3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ "string text 123", "string text 100", "string text 555", ]; var_dump(array_reduce($arr, function(array $carry, string $value): array { $prefix = substr($value, 0, 12); $carry[$prefix][] = $value; return $carry; }, []));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9pZMV
function name:  (null)
number of ops:  11
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9pZMV%3A8%240'
   12     5        SEND_VAL                                                 ~2
          6        SEND_VAL                                                 <array>
          7        DO_ICALL                                         $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F9pZMV%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9pZMV
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $carry, !1 = $value, !2 = $prefix
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        INIT_FCALL                                               'substr'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 12
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !2, $3
   10     8        FETCH_DIM_W                                      $5      !0, !2
          9        ASSIGN_DIM                                               $5
         10        OP_DATA                                                  !1
   11    11        VERIFY_RETURN_TYPE                                       !0
         12      > RETURN                                                   !0
   12    13*       VERIFY_RETURN_TYPE                                       
         14*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9pZMV%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
207.68 ms | 1395 KiB | 19 Q