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(ValueAddedParams $params){ $retPortraitArr = array(); $portraitArr = json_decode($params->getUserPortraitInfo(), true); $fields = ValueAdded::$FIELDS; foreach($portraitArr as $key => $portrait){ foreach($fields as $field){ $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/CoXoF
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 = 12, Position 2 = 32
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 32
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 30
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 30
Branch analysis from position: 16
2 jumps found. (Code = 46) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 21
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
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/CoXoF
function name:  constructPortrait
number of ops:  35
compiled vars:  !0 = $params, !1 = $retPortraitArr, !2 = $portraitArr, !3 = $fields, !4 = $portrait, !5 = $key, !6 = $field
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        ASSIGN                                                   !1, <array>
   22     2        INIT_FCALL                                               'json_decode'
          3        INIT_METHOD_CALL                                         !0, 'getUserPortraitInfo'
          4        DO_FCALL                                      0  $8      
          5        SEND_VAR                                                 $8
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !2, $9
   23     9        FETCH_STATIC_PROP_R          unknown             ~11     'FIELDS'
         10        ASSIGN                                                   !3, ~11
   24    11      > FE_RESET_R                                       $13     !2, ->32
         12    > > FE_FETCH_R                                       ~14     $13, !4, ->32
         13    >   ASSIGN                                                   !5, ~14
   25    14      > FE_RESET_R                                       $16     !3, ->30
         15    > > FE_FETCH_R                                               $16, !6, ->30
   26    16    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~19     !4, !5
         17      > JMPZ_EX                                          ~19     ~19, ->21
         18    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~20     !4, !5
         19        BOOL_NOT                                         ~21     ~20
         20        BOOL                                             ~19     ~21
         21    > > JMPZ                                                     ~19, ->25
         22    >   FETCH_DIM_R                                      ~22     !4, !5
         23        QM_ASSIGN                                        ~23     ~22
         24      > JMP                                                      ->26
         25    >   QM_ASSIGN                                        ~23     ''
         26    >   FETCH_DIM_W                                      $17     !1, !5
         27        ASSIGN_DIM                                               $17, !6
         28        OP_DATA                                                  ~23
   25    29      > JMP                                                      ->15
         30    >   FE_FREE                                                  $16
   24    31      > JMP                                                      ->12
         32    >   FE_FREE                                                  $13
   30    33      > RETURN                                                   !1
   33    34*     > RETURN                                                   null

End of function constructportrait

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.7 ms | 1411 KiB | 18 Q