3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input1 = [ '0' => [ 'foo01' => 'value01', 'bar02' => 'value02', 'formats01' => [ 'subfoo_011' => 'subvalue_011', 'subfoo_012' => 'subvalue_012', ] ], '1' => [ 'foo11' => 'value11', 'bar12' => 'value12', 'formats02' => [ 'subfoo_021' => 'subvalue_021', 'subfoo_022' => 'subvalue_022', ] ] ]; $input2 = [ 'foo' => 'value1', 'bar' => 'value2', 'formats' => [ 'foo' => 'value_1', 'bar' => 'value_2', ] ]; function countValues(array $array) { $i = 0; foreach ($array as $arrayKey => $data) { $i++; $ii = 0; foreach ($data as $key => $value) { $ii++; if (!is_array($value)) { $newArray[':' . $key . '_' . $i . '_' . $ii] = $value; } else if (is_array($value)) { foreach ($value as $subKey => $subValue) { $newArray[':' . $subKey . '_' . $i . '_' . $ii] = $subValue; } } } } return $newArray; } var_dump(countValues($input1)); var_dump(countValues($input2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gJkZa
function name:  (null)
number of ops:  15
compiled vars:  !0 = $input1, !1 = $input2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        ASSIGN                                                   !1, <array>
   54     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'countvalues'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
   55     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'countvalues'
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0  $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function countvalues:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 39
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 39
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 37
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 37
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 36
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 35
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 35
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 35
Branch analysis from position: 36
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 37
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/gJkZa
function name:  countValues
number of ops:  42
compiled vars:  !0 = $array, !1 = $i, !2 = $data, !3 = $arrayKey, !4 = $ii, !5 = $value, !6 = $key, !7 = $newArray, !8 = $subValue, !9 = $subKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   35     1        ASSIGN                                                   !1, 0
   36     2      > FE_RESET_R                                       $11     !0, ->39
          3    > > FE_FETCH_R                                       ~12     $11, !2, ->39
          4    >   ASSIGN                                                   !3, ~12
   37     5        PRE_INC                                                  !1
   38     6        ASSIGN                                                   !4, 0
   39     7      > FE_RESET_R                                       $16     !2, ->37
          8    > > FE_FETCH_R                                       ~17     $16, !5, ->37
          9    >   ASSIGN                                                   !6, ~17
   40    10        PRE_INC                                                  !4
   41    11        TYPE_CHECK                                  128  ~20     !5
         12        BOOL_NOT                                         ~21     ~20
         13      > JMPZ                                                     ~21, ->22
   42    14    >   CONCAT                                           ~22     '%3A', !6
         15        CONCAT                                           ~23     ~22, '_'
         16        CONCAT                                           ~24     ~23, !1
         17        CONCAT                                           ~25     ~24, '_'
         18        CONCAT                                           ~26     ~25, !4
         19        ASSIGN_DIM                                               !7, ~26
         20        OP_DATA                                                  !5
         21      > JMP                                                      ->36
   43    22    >   TYPE_CHECK                                  128          !5
         23      > JMPZ                                                     ~28, ->36
   44    24    > > FE_RESET_R                                       $29     !5, ->35
         25    > > FE_FETCH_R                                       ~30     $29, !8, ->35
         26    >   ASSIGN                                                   !9, ~30
   45    27        CONCAT                                           ~32     '%3A', !9
         28        CONCAT                                           ~33     ~32, '_'
         29        CONCAT                                           ~34     ~33, !1
         30        CONCAT                                           ~35     ~34, '_'
         31        CONCAT                                           ~36     ~35, !4
         32        ASSIGN_DIM                                               !7, ~36
         33        OP_DATA                                                  !8
   44    34      > JMP                                                      ->25
         35    >   FE_FREE                                                  $29
   39    36    > > JMP                                                      ->8
         37    >   FE_FREE                                                  $16
   36    38      > JMP                                                      ->3
         39    >   FE_FREE                                                  $11
   50    40      > RETURN                                                   !7
   51    41*     > RETURN                                                   null

End of function countvalues

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.84 ms | 1403 KiB | 17 Q