3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( 'a', 'b', 'c' => array(1,2) ); $formt = array( 'A' => array( 'is_need' => true, 'type_condition' => 'or', 'type' => false, ), 'B', 'C' => array( 'child' => array( 'C1' => array( 'is_need' => true, 'type_condition' => 'or', 'type' => false, ), 'C2' => array( 'is_need' => true, 'type_condition' => 'or', 'type' => false, ), ) ), ); function formatParams($arr, $formt) { list($f_k, $f_v) = each($formt); $data = array(); foreach($arr as $key => $val) { if(is_array($val)) { $data[$f_k] = formatParams($val, $f_v['child']); } else { if(is_array($f_v)) { $data[$f_k] = $val; } else { $data[$f_v] = $val; } } list($f_k, $f_v) = each($formt); } return $data; } // var_dump(formatParams($arr, $formt)); list($key, $val) = each($arr); for($i = 0; $i <= 4;++$i) { echo $key . "\n"; echo (list($key, $val) = each($arr)) . "\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 12
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 12
Branch analysis from position: 26
Branch analysis from position: 12
filename:       /in/HM1AV
function name:  (null)
number of ops:  27
compiled vars:  !0 = $arr, !1 = $formt, !2 = $key, !3 = $val, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    6     1        ASSIGN                                                   !1, <array>
   46     2        INIT_FCALL_BY_NAME                                       'each'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $7      
          5        FETCH_LIST_R                                     $8      $7, 0
          6        ASSIGN                                                   !2, $8
          7        FETCH_LIST_R                                     $10     $7, 1
          8        ASSIGN                                                   !3, $10
          9        FREE                                                     $7
   47    10        ASSIGN                                                   !4, 0
         11      > JMP                                                      ->24
   48    12    >   CONCAT                                           ~13     !2, '%0A'
         13        ECHO                                                     ~13
   49    14        INIT_FCALL_BY_NAME                                       'each'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0  $14     
         17        FETCH_LIST_R                                     $15     $14, 0
         18        ASSIGN                                                   !2, $15
         19        FETCH_LIST_R                                     $17     $14, 1
         20        ASSIGN                                                   !3, $17
         21        CONCAT                                           ~19     $14, '%0A'
         22        ECHO                                                     ~19
   47    23        PRE_INC                                                  !4
         24    >   IS_SMALLER_OR_EQUAL                                      !4, 4
         25      > JMPNZ                                                    ~21, ->12
   50    26    > > RETURN                                                   1

Function formatparams:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 41
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 41
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 25
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/HM1AV
function name:  formatParams
number of ops:  44
compiled vars:  !0 = $arr, !1 = $formt, !2 = $f_k, !3 = $f_v, !4 = $data, !5 = $val, !6 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   29     2        INIT_FCALL_BY_NAME                                       'each'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0  $7      
          5        FETCH_LIST_R                                     $8      $7, 0
          6        ASSIGN                                                   !2, $8
          7        FETCH_LIST_R                                     $10     $7, 1
          8        ASSIGN                                                   !3, $10
          9        FREE                                                     $7
   30    10        ASSIGN                                                   !4, <array>
   31    11      > FE_RESET_R                                       $13     !0, ->41
         12    > > FE_FETCH_R                                       ~14     $13, !5, ->41
         13    >   ASSIGN                                                   !6, ~14
   32    14        TYPE_CHECK                                  128          !5
         15      > JMPZ                                                     ~16, ->25
   33    16    >   INIT_FCALL_BY_NAME                                       'formatParams'
         17        SEND_VAR_EX                                              !5
         18        CHECK_FUNC_ARG                                           
         19        FETCH_DIM_FUNC_ARG                               $18     !3, 'child'
         20        SEND_FUNC_ARG                                            $18
         21        DO_FCALL                                      0  $19     
         22        ASSIGN_DIM                                               !4, !2
         23        OP_DATA                                                  $19
         24      > JMP                                                      ->32
   35    25    >   TYPE_CHECK                                  128          !3
         26      > JMPZ                                                     ~20, ->30
   36    27    >   ASSIGN_DIM                                               !4, !2
         28        OP_DATA                                                  !5
         29      > JMP                                                      ->32
   38    30    >   ASSIGN_DIM                                               !4, !3
         31        OP_DATA                                                  !5
   41    32    >   INIT_FCALL_BY_NAME                                       'each'
         33        SEND_VAR_EX                                              !1
         34        DO_FCALL                                      0  $23     
         35        FETCH_LIST_R                                     $24     $23, 0
         36        ASSIGN                                                   !2, $24
         37        FETCH_LIST_R                                     $26     $23, 1
         38        ASSIGN                                                   !3, $26
         39        FREE                                                     $23
   31    40      > JMP                                                      ->12
         41    >   FE_FREE                                                  $13
   43    42      > RETURN                                                   !4
   44    43*     > RETURN                                                   null

End of function formatparams

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.46 ms | 1399 KiB | 13 Q