3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( Array ( 'sexo_edad' => 'type1', 'fans' => 2 ), Array ( 'sexo_edad' => 'type2', 'fans' => 3 ), Array ( 'sexo_edad' => 'type1', 'fans' => 8 ), Array ( 'sexo_edad' => 'type2', 'fans' => 10 ) ); $type_values = array(); foreach ($array as &$arr) { if (isset($type_values[$arr['sexo_edad']])) { $arr['difference'] = $arr['fans'] - $type_values[$arr['sexo_edad']]; } else { $arr['difference'] = 0; } $type_values[$arr['sexo_edad']] = $arr['fans']; } print_r($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/GW8m0
function name:  (null)
number of ops:  26
compiled vars:  !0 = $array, !1 = $type_values, !2 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   28     1        ASSIGN                                                   !1, <array>
   29     2      > FE_RESET_RW                                      $5      !0, ->21
          3    > > FE_FETCH_RW                                              $5, !2, ->21
   30     4    >   FETCH_DIM_R                                      ~6      !2, 'sexo_edad'
          5        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~6
          6      > JMPZ                                                     ~7, ->14
   31     7    >   FETCH_DIM_R                                      ~9      !2, 'fans'
          8        FETCH_DIM_R                                      ~10     !2, 'sexo_edad'
          9        FETCH_DIM_R                                      ~11     !1, ~10
         10        SUB                                              ~12     ~9, ~11
         11        ASSIGN_DIM                                               !2, 'difference'
         12        OP_DATA                                                  ~12
         13      > JMP                                                      ->16
   34    14    >   ASSIGN_DIM                                               !2, 'difference'
         15        OP_DATA                                                  0
   36    16    >   FETCH_DIM_R                                      ~14     !2, 'sexo_edad'
         17        FETCH_DIM_R                                      ~16     !2, 'fans'
         18        ASSIGN_DIM                                               !1, ~14
         19        OP_DATA                                                  ~16
   29    20      > JMP                                                      ->3
         21    >   FE_FREE                                                  $5
   38    22        INIT_FCALL                                               'print_r'
         23        SEND_VAR                                                 !0
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.15 ms | 1401 KiB | 15 Q