3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'key_1' => 'FOO', 'key_2' => 'FTU-1', 'cats' => '/30/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-2', 'cats' => '/30/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-3', 'cats' => '/30/10/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-4', 'cats' => '/15/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-5', 'cats' => '/10/' ], [ 'key_1' => 'FOO', 'key_2' => 'FTU-6', 'cats' => '/15/' ], ]; $result = []; foreach ($array as $row) { foreach (explode('/', trim($row['cats'], '/')) as $cat) { $result[$cat][] = $row; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/ZsrKa
function name:  (null)
number of ops:  26
compiled vars:  !0 = $array, !1 = $result, !2 = $row, !3 = $cat
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        ASSIGN                                                   !1, <array>
   37     2      > FE_RESET_R                                       $6      !0, ->21
          3    > > FE_FETCH_R                                               $6, !2, ->21
   38     4    >   INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '%2F'
          6        INIT_FCALL                                               'trim'
          7        FETCH_DIM_R                                      ~7      !2, 'cats'
          8        SEND_VAL                                                 ~7
          9        SEND_VAL                                                 '%2F'
         10        DO_ICALL                                         $8      
         11        SEND_VAR                                                 $8
         12        DO_ICALL                                         $9      
         13      > FE_RESET_R                                       $10     $9, ->19
         14    > > FE_FETCH_R                                               $10, !3, ->19
   39    15    >   FETCH_DIM_W                                      $11     !1, !3
         16        ASSIGN_DIM                                               $11
         17        OP_DATA                                                  !2
   38    18      > JMP                                                      ->14
         19    >   FE_FREE                                                  $10
   37    20      > JMP                                                      ->3
         21    >   FE_FREE                                                  $6
   42    22        INIT_FCALL                                               'var_export'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.56 ms | 1013 KiB | 16 Q