3v4l.org

run code in 300+ PHP versions simultaneously
<?php function flatten($arr) { $result = []; foreach ($arr as $key => $value) { if (is_array($value)) { foreach ($this->flatten($value) as $subKey => $scalar) { $result[$key . ':' . $subKey] = $scalar; } } else if (is_scalar($value)) { $result[$key] = $value; } } return $result; } var_dump(['foo' => 123, 'bar' => 456]); var_dump(['foo' => ['bar' => 123, 'baz' => 456]]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Y9rWC
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'var_dump'
          1        SEND_VAL                                                 <array>
          2        DO_ICALL                                                 
   21     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAL                                                 <array>
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function flatten:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 26
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 19
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: 19
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 25
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/Y9rWC
function name:  flatten
number of ops:  29
compiled vars:  !0 = $arr, !1 = $result, !2 = $value, !3 = $key, !4 = $scalar, !5 = $subKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
    7     2      > FE_RESET_R                                       $7      !0, ->26
          3    > > FE_FETCH_R                                       ~8      $7, !2, ->26
          4    >   ASSIGN                                                   !3, ~8
    8     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~10, ->21
    9     7    >   FETCH_THIS                                       $11     
          8        INIT_METHOD_CALL                                         $11, 'flatten'
          9        SEND_VAR_EX                                              !2
         10        DO_FCALL                                      0  $12     
         11      > FE_RESET_R                                       $13     $12, ->19
         12    > > FE_FETCH_R                                       ~14     $13, !4, ->19
         13    >   ASSIGN                                                   !5, ~14
   10    14        CONCAT                                           ~16     !3, '%3A'
         15        CONCAT                                           ~17     ~16, !5
         16        ASSIGN_DIM                                               !1, ~17
         17        OP_DATA                                                  !4
    9    18      > JMP                                                      ->12
         19    >   FE_FREE                                                  $13
         20      > JMP                                                      ->25
   12    21    >   TYPE_CHECK                                  124          !2
         22      > JMPZ                                                     ~19, ->25
   13    23    >   ASSIGN_DIM                                               !1, !3
         24        OP_DATA                                                  !2
    7    25    > > JMP                                                      ->3
         26    >   FE_FREE                                                  $7
   17    27      > RETURN                                                   !1
   18    28*     > RETURN                                                   null

End of function flatten

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.42 ms | 1400 KiB | 15 Q