3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "prefix1 foo", "prefix2 bar", "prefix1 aaa", "prefix2 bbb", "prefix3 ccc", "prefix1 111", "prefix2 222" ]; foreach ($array as $v) { [$prefix, $value] = explode(' ', $v, 2); if (isset($batch[$prefix])) { $result[] = $batch; $batch = [$prefix => $value]; } else{ $batch[$prefix] = $value; } } $result[] = $batch; var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 23
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/tA1LR
function name:  (null)
number of ops:  30
compiled vars:  !0 = $array, !1 = $v, !2 = $prefix, !3 = $value, !4 = $batch, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   12     1      > FE_RESET_R                                       $7      !0, ->23
          2    > > FE_FETCH_R                                               $7, !1, ->23
   13     3    >   INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '+'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 2
          7        DO_ICALL                                         $8      
          8        FETCH_LIST_R                                     $9      $8, 0
          9        ASSIGN                                                   !2, $9
         10        FETCH_LIST_R                                     $11     $8, 1
         11        ASSIGN                                                   !3, $11
         12        FREE                                                     $8
   14    13        ISSET_ISEMPTY_DIM_OBJ                         0          !4, !2
         14      > JMPZ                                                     ~13, ->20
   15    15    >   ASSIGN_DIM                                               !5
         16        OP_DATA                                                  !4
   16    17        INIT_ARRAY                                       ~15     !3, !2
         18        ASSIGN                                                   !4, ~15
         19      > JMP                                                      ->22
   18    20    >   ASSIGN_DIM                                               !4, !2
         21        OP_DATA                                                  !3
   12    22    > > JMP                                                      ->2
         23    >   FE_FREE                                                  $7
   21    24        ASSIGN_DIM                                               !5
         25        OP_DATA                                                  !4
   22    26        INIT_FCALL                                               'var_export'
         27        SEND_VAR                                                 !5
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.69 ms | 1401 KiB | 17 Q