3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = ' Balthazar - True Love # Maarten Devoldere Adani & Wolf - Let It Go # Daniel Testas Adani & Wolf - Let It Go # Rob Gaasterland Balthazar - True Love # Maarten Devoldere Balthazar - True Love # Jinte Deprez Balthazar - True Love # Name 3 '; preg_match_all('/^([^#]+)#([^\n]+)/m', trim($text), $matches, PREG_SET_ORDER); foreach ($matches as $v) { $result[trim($v[1])][] = trim($v[2]); } foreach ($result as $k => $v){ echo $k .' # '. join(', ', $v) . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 24
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 24
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 37
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 37
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 24
filename:       /in/WY1kP
function name:  (null)
number of ops:  39
compiled vars:  !0 = $text, !1 = $matches, !2 = $v, !3 = $result, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%0A++++Balthazar+-+True+Love+%23+Maarten+Devoldere++%0A++++Adani+%26+Wolf+-+Let+It+Go+%23+Daniel+Testas++%0A++++Adani+%26+Wolf+-+Let+It+Go+%23+Rob+Gaasterland++%0A++++Balthazar+-+True+Love+%23+Maarten+Devoldere++%0A++++Balthazar+-+True+Love+%23+Jinte+Deprez++%0A++++Balthazar+-+True+Love+%23+Name+3+%0A'
   12     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%5E%28%5B%5E%23%5D%2B%29%23%28%5B%5E%5Cn%5D%2B%29%2Fm'
          3        INIT_FCALL                                               'trim'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6        SEND_VAR                                                 $6
          7        SEND_REF                                                 !1
          8        SEND_VAL                                                 2
          9        DO_ICALL                                                 
   14    10      > FE_RESET_R                                       $8      !1, ->24
         11    > > FE_FETCH_R                                               $8, !2, ->24
   15    12    >   INIT_FCALL                                               'trim'
         13        FETCH_DIM_R                                      ~9      !2, 1
         14        SEND_VAL                                                 ~9
         15        DO_ICALL                                         $10     
         16        INIT_FCALL                                               'trim'
         17        FETCH_DIM_R                                      ~13     !2, 2
         18        SEND_VAL                                                 ~13
         19        DO_ICALL                                         $14     
         20        FETCH_DIM_W                                      $11     !3, $10
         21        ASSIGN_DIM                                               $11
         22        OP_DATA                                                  $14
   14    23      > JMP                                                      ->11
         24    >   FE_FREE                                                  $8
   18    25      > FE_RESET_R                                       $15     !3, ->37
         26    > > FE_FETCH_R                                       ~16     $15, !2, ->37
         27    >   ASSIGN                                                   !4, ~16
   19    28        CONCAT                                           ~18     !4, '+%23+'
         29        INIT_FCALL                                               'join'
         30        SEND_VAL                                                 '%2C+'
         31        SEND_VAR                                                 !2
         32        DO_ICALL                                         $19     
         33        CONCAT                                           ~20     ~18, $19
         34        CONCAT                                           ~21     ~20, '%0A'
         35        ECHO                                                     ~21
   18    36      > JMP                                                      ->26
         37    >   FE_FREE                                                  $15
   20    38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.56 ms | 1400 KiB | 19 Q