3v4l.org

run code in 300+ PHP versions simultaneously
<?php $features = [ "width: 100 m", "method: Nail Down", "method: Main Floor", "Warranty: 25 years", "Color: Red", "Color: Blue" ]; $features = array_reduce($features, function($carry, $item){ $parts = explode(":", $item); $carry[$parts[0]][] = $parts[1]; return $carry; }); foreach ($features as $key => $value) { echo "$key: " . implode(',', $value) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/WoAdp
function name:  (null)
number of ops:  22
compiled vars:  !0 = $features, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FWoAdp%3A12%240'
   16     4        SEND_VAL                                                 ~4
          5        DO_ICALL                                         $5      
   12     6        ASSIGN                                                   !0, $5
   18     7      > FE_RESET_R                                       $7      !0, ->20
          8    > > FE_FETCH_R                                       ~8      $7, !1, ->20
          9    >   ASSIGN                                                   !2, ~8
   19    10        NOP                                                      
         11        FAST_CONCAT                                      ~10     !2, '%3A+'
         12        INIT_FCALL                                               'implode'
         13        SEND_VAL                                                 '%2C'
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $11     
         16        CONCAT                                           ~12     ~10, $11
         17        CONCAT                                           ~13     ~12, '%0A'
         18        ECHO                                                     ~13
   18    19      > JMP                                                      ->8
         20    >   FE_FREE                                                  $7
   20    21      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FWoAdp%3A12%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
12.32 ms | 416 KiB | 7 Q