3v4l.org

run code in 300+ PHP versions simultaneously
<?php $j[] = 'ma_1_49812_5318.jpg'; $j[] = 'ma_1_49812_5319.jpg'; $j[] = 'ma_1_49813_5320.jpg'; $j[] = 'ma_1_49813_5321.jpg'; $result = []; foreach ($j as $filename) { $groupBy = preg_replace('/_[^_]+$/', '', $filename); if (!isset($ref[$groupBy])) { $ref[$groupBy] = $filename; $result[] = &$ref[$groupBy]; } else { $ref[$groupBy] .= "|$filename"; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 32
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 32
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/TBbUF
function name:  (null)
number of ops:  37
compiled vars:  !0 = $j, !1 = $result, !2 = $filename, !3 = $groupBy, !4 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN_DIM                                               !0
          1        OP_DATA                                                  'ma_1_49812_5318.jpg'
    4     2        ASSIGN_DIM                                               !0
          3        OP_DATA                                                  'ma_1_49812_5319.jpg'
    5     4        ASSIGN_DIM                                               !0
          5        OP_DATA                                                  'ma_1_49813_5320.jpg'
    6     6        ASSIGN_DIM                                               !0
          7        OP_DATA                                                  'ma_1_49813_5321.jpg'
    8     8        ASSIGN                                                   !1, <array>
    9     9      > FE_RESET_R                                       $10     !0, ->32
         10    > > FE_FETCH_R                                               $10, !2, ->32
   10    11    >   INIT_FCALL                                               'preg_replace'
         12        SEND_VAL                                                 '%2F_%5B%5E_%5D%2B%24%2F'
         13        SEND_VAL                                                 ''
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $11     
         16        ASSIGN                                                   !3, $11
   11    17        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !4, !3
         18        BOOL_NOT                                         ~14     ~13
         19      > JMPZ                                                     ~14, ->27
   12    20    >   ASSIGN_DIM                                               !4, !3
         21        OP_DATA                                                  !2
   13    22        FETCH_DIM_W                                      $17     !4, !3
         23        MAKE_REF                                         $18     $17
         24        FETCH_DIM_W                                      $16     !1
         25        ASSIGN_REF                                               $16, $18
   11    26      > JMP                                                      ->31
   15    27    >   NOP                                                      
         28        FAST_CONCAT                                      ~21     '%7C', !2
         29        ASSIGN_DIM_OP                .=               8          !4, !3
         30        OP_DATA                                                  ~21
    9    31    > > JMP                                                      ->10
         32    >   FE_FREE                                                  $10
   18    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.32 ms | 1008 KiB | 15 Q