3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = array( 'gid'=>1, 'phone_number'=>1, 'weibo'=>1, 'qq'=>1, 'email'=>1, 'gender'=>1, 'age'=>1, 'area'=>1, 'computer'=>1, 'phone'=>1, 'valid_user'=>1, 'bank'=>json_encode(array(1,2,3)), 'tag_big'=>json_encode(array(1,2,3)), 'tag_medium'=>json_encode(array(1,2,3)), 'tag_small'=>json_encode(array(1,2,3)), 'family'=>json_encode(array(1,2,3)), 'friend'=>json_encode(array(1,2,3)), 'visitor'=>json_encode(array(1,2,3)) ); $field = array( 'gid', 'phone_number', 'weibo', 'qq', 'email', 'gender', 'age', 'area', 'computer', 'phone', 'valid_user', 'bank', 'tag_big', 'tag_medium', 'tag_small', 'family', 'friend', 'visitor' ); function constructPortrait($fields, $test){ $retPortraitArr = array(); $portraitArr = array($test); foreach($portraitArr as $key => $portrait){ foreach($fields as $field){ var_dump($fields, portrait);exit; $retPortraitArr[$key][$field] = isset($portrait[$key]) && !empty($portrait[$key]) ? $portrait[$key] : ''; } } return $retPortraitArr; } echo json_encode(constructPortrait($field, $test));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j7nVu
function name:  (null)
number of ops:  50
compiled vars:  !0 = $test, !1 = $field
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_ARRAY                                       ~2      1, 'gid'
          1        ADD_ARRAY_ELEMENT                                ~2      1, 'phone_number'
          2        ADD_ARRAY_ELEMENT                                ~2      1, 'weibo'
    5     3        ADD_ARRAY_ELEMENT                                ~2      1, 'qq'
          4        ADD_ARRAY_ELEMENT                                ~2      1, 'email'
          5        ADD_ARRAY_ELEMENT                                ~2      1, 'gender'
    6     6        ADD_ARRAY_ELEMENT                                ~2      1, 'age'
          7        ADD_ARRAY_ELEMENT                                ~2      1, 'area'
          8        ADD_ARRAY_ELEMENT                                ~2      1, 'computer'
    7     9        ADD_ARRAY_ELEMENT                                ~2      1, 'phone'
         10        ADD_ARRAY_ELEMENT                                ~2      1, 'valid_user'
         11        INIT_FCALL                                               'json_encode'
         12        SEND_VAL                                                 <array>
         13        DO_ICALL                                         $3      
         14        ADD_ARRAY_ELEMENT                                ~2      $3, 'bank'
    8    15        INIT_FCALL                                               'json_encode'
         16        SEND_VAL                                                 <array>
         17        DO_ICALL                                         $4      
         18        ADD_ARRAY_ELEMENT                                ~2      $4, 'tag_big'
         19        INIT_FCALL                                               'json_encode'
         20        SEND_VAL                                                 <array>
         21        DO_ICALL                                         $5      
         22        ADD_ARRAY_ELEMENT                                ~2      $5, 'tag_medium'
         23        INIT_FCALL                                               'json_encode'
         24        SEND_VAL                                                 <array>
         25        DO_ICALL                                         $6      
         26        ADD_ARRAY_ELEMENT                                ~2      $6, 'tag_small'
    9    27        INIT_FCALL                                               'json_encode'
         28        SEND_VAL                                                 <array>
         29        DO_ICALL                                         $7      
         30        ADD_ARRAY_ELEMENT                                ~2      $7, 'family'
         31        INIT_FCALL                                               'json_encode'
         32        SEND_VAL                                                 <array>
         33        DO_ICALL                                         $8      
         34        ADD_ARRAY_ELEMENT                                ~2      $8, 'friend'
         35        INIT_FCALL                                               'json_encode'
         36        SEND_VAL                                                 <array>
         37        DO_ICALL                                         $9      
         38        ADD_ARRAY_ELEMENT                                ~2      $9, 'visitor'
    3    39        ASSIGN                                                   !0, ~2
   12    40        ASSIGN                                                   !1, <array>
   35    41        INIT_FCALL                                               'json_encode'
         42        INIT_FCALL                                               'constructportrait'
         43        SEND_VAR                                                 !1
         44        SEND_VAR                                                 !0
         45        DO_FCALL                                      0  $12     
         46        SEND_VAR                                                 $12
         47        DO_ICALL                                         $13     
         48        ECHO                                                     $13
         49      > RETURN                                                   1

Function constructportrait:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 32
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 32
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 30
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 30
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/j7nVu
function name:  constructPortrait
number of ops:  35
compiled vars:  !0 = $fields, !1 = $test, !2 = $retPortraitArr, !3 = $portraitArr, !4 = $portrait, !5 = $key, !6 = $field
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        ASSIGN                                                   !2, <array>
   22     3        INIT_ARRAY                                       ~8      !1
          4        ASSIGN                                                   !3, ~8
   23     5      > FE_RESET_R                                       $10     !3, ->32
          6    > > FE_FETCH_R                                       ~11     $10, !4, ->32
          7    >   ASSIGN                                                   !5, ~11
   24     8      > FE_RESET_R                                       $13     !0, ->30
          9    > > FE_FETCH_R                                               $13, !6, ->30
   25    10    >   INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !0
         12        FETCH_CONSTANT                                   ~14     'portrait'
         13        SEND_VAL                                                 ~14
         14        DO_ICALL                                                 
         15      > EXIT                                                     
   26    16*       ISSET_ISEMPTY_DIM_OBJ                         0  ~18     !4, !5
         17*       JMPZ_EX                                          ~18     ~18, ->21
         18*       ISSET_ISEMPTY_DIM_OBJ                         1  ~19     !4, !5
         19*       BOOL_NOT                                         ~20     ~19
         20*       BOOL                                             ~18     ~20
         21*       JMPZ                                                     ~18, ->25
         22*       FETCH_DIM_R                                      ~21     !4, !5
         23*       QM_ASSIGN                                        ~22     ~21
         24*       JMP                                                      ->26
         25*       QM_ASSIGN                                        ~22     ''
         26*       FETCH_DIM_W                                      $16     !2, !5
         27*       ASSIGN_DIM                                               $16, !6
         28*       OP_DATA                                                  ~22
   24    29*       JMP                                                      ->9
         30    >   FE_FREE                                                  $13
   23    31      > JMP                                                      ->6
         32    >   FE_FREE                                                  $10
   30    33      > RETURN                                                   !2
   33    34*     > RETURN                                                   null

End of function constructportrait

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.22 ms | 1411 KiB | 18 Q