3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = Array ( 0 => Array ( 'template_id' => 1, 'template_field_id' => 20 ), 1 => Array ( 'template_id' => 1, 'template_field_id' => 21 ), 2 => Array ( 'template_id' => 2, 'template_field_id' => 22 ), 3 => Array ( 'template_id' => 2, 'template_field_id' => 23 ) ); $newarr = array(); foreach($arr as $key=>$val){ $newarr[$val['template_id']][] = $val; } $i=0; foreach($newarr as $k=>$v){ foreach($v as $m){ $newarr1[$i]['id']= $m['template_id']; $newarr1[$i]['template_field_id'][]['id']= $m['template_field_id']; } $i++; } echo "<pre>"; print_r($newarr1);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 31
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 31
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 28
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 28
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 28
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
Branch analysis from position: 10
filename:       /in/hBHnM
function name:  (null)
number of ops:  37
compiled vars:  !0 = $arr, !1 = $newarr, !2 = $val, !3 = $key, !4 = $i, !5 = $v, !6 = $k, !7 = $m, !8 = $newarr1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   31     1        ASSIGN                                                   !1, <array>
   32     2      > FE_RESET_R                                       $11     !0, ->10
          3    > > FE_FETCH_R                                       ~12     $11, !2, ->10
          4    >   ASSIGN                                                   !3, ~12
   33     5        FETCH_DIM_R                                      ~14     !2, 'template_id'
          6        FETCH_DIM_W                                      $15     !1, ~14
          7        ASSIGN_DIM                                               $15
          8        OP_DATA                                                  !2
   32     9      > JMP                                                      ->3
         10    >   FE_FREE                                                  $11
   36    11        ASSIGN                                                   !4, 0
   37    12      > FE_RESET_R                                       $18     !1, ->31
         13    > > FE_FETCH_R                                       ~19     $18, !5, ->31
         14    >   ASSIGN                                                   !6, ~19
   38    15      > FE_RESET_R                                       $21     !5, ->28
         16    > > FE_FETCH_R                                               $21, !7, ->28
   39    17    >   FETCH_DIM_R                                      ~24     !7, 'template_id'
         18        FETCH_DIM_W                                      $22     !8, !4
         19        ASSIGN_DIM                                               $22, 'id'
         20        OP_DATA                                                  ~24
   40    21        FETCH_DIM_R                                      ~29     !7, 'template_field_id'
         22        FETCH_DIM_W                                      $25     !8, !4
         23        FETCH_DIM_W                                      $26     $25, 'template_field_id'
         24        FETCH_DIM_W                                      $27     $26
         25        ASSIGN_DIM                                               $27, 'id'
         26        OP_DATA                                                  ~29
   38    27      > JMP                                                      ->16
         28    >   FE_FREE                                                  $21
   42    29        PRE_INC                                                  !4
   37    30      > JMP                                                      ->13
         31    >   FE_FREE                                                  $18
   44    32        ECHO                                                     '%3Cpre%3E'
         33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !8
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.9 ms | 1015 KiB | 14 Q