3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array('num'=>5,'period'=>3), array('num'=>10,'period'=>3), array('num'=>15,'period'=>9) ); $temp = array(); foreach($arr as $item) { list($n, $p) = array_values($item);print_r($p);print_r($n); $temp[$p] = array_key_exists($p, $temp) ? $temp[$p]+$n : $n; } print_r($temp); $arr = array(); foreach($temp as $p => $n) $arr[] = array('num'=>$n, 'period'=>$p); print_r($arr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 28
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 28
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 41
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 41
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 28
filename:       /in/4NONP
function name:  (null)
number of ops:  46
compiled vars:  !0 = $arr, !1 = $temp, !2 = $item, !3 = $n, !4 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   12     2      > FE_RESET_R                                       $7      !0, ->28
          3    > > FE_FETCH_R                                               $7, !2, ->28
   13     4    >   INIT_FCALL                                               'array_values'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $8      
          7        FETCH_LIST_R                                     $9      $8, 0
          8        ASSIGN                                                   !3, $9
          9        FETCH_LIST_R                                     $11     $8, 1
         10        ASSIGN                                                   !4, $11
         11        FREE                                                     $8
         12        INIT_FCALL                                               'print_r'
         13        SEND_VAR                                                 !4
         14        DO_ICALL                                                 
         15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                                 
   14    18        ARRAY_KEY_EXISTS                                         !4, !1
         19      > JMPZ                                                     ~16, ->24
         20    >   FETCH_DIM_R                                      ~17     !1, !4
         21        ADD                                              ~18     ~17, !3
         22        QM_ASSIGN                                        ~19     ~18
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~19     !3
         25    >   ASSIGN_DIM                                               !1, !4
         26        OP_DATA                                                  ~19
   12    27      > JMP                                                      ->3
         28    >   FE_FREE                                                  $7
   16    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                                 
   17    32        ASSIGN                                                   !0, <array>
   18    33      > FE_RESET_R                                       $22     !1, ->41
         34    > > FE_FETCH_R                                       ~23     $22, !3, ->41
         35    >   ASSIGN                                                   !4, ~23
   19    36        INIT_ARRAY                                       ~26     !3, 'num'
         37        ADD_ARRAY_ELEMENT                                ~26     !4, 'period'
         38        ASSIGN_DIM                                               !0
         39        OP_DATA                                                  ~26
   18    40      > JMP                                                      ->34
         41    >   FE_FREE                                                  $22
   21    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !0
         44        DO_ICALL                                                 
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.35 ms | 1400 KiB | 17 Q