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){ $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/EeCCN
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>
   34    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 = 26
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 26
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 15
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 24
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/EeCCN
function name:  constructPortrait
number of ops:  29
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, ->26
          6    > > FE_FETCH_R                                       ~11     $10, !4, ->26
          7    >   ASSIGN                                                   !5, ~11
   24     8      > FE_RESET_R                                       $13     !0, ->24
          9    > > FE_FETCH_R                                               $13, !6, ->24
   25    10    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~16     !4, !5
         11      > JMPZ_EX                                          ~16     ~16, ->15
         12    >   ISSET_ISEMPTY_DIM_OBJ                         1  ~17     !4, !5
         13        BOOL_NOT                                         ~18     ~17
         14        BOOL                                             ~16     ~18
         15    > > JMPZ                                                     ~16, ->19
         16    >   FETCH_DIM_R                                      ~19     !4, !5
         17        QM_ASSIGN                                        ~20     ~19
         18      > JMP                                                      ->20
         19    >   QM_ASSIGN                                        ~20     ''
         20    >   FETCH_DIM_W                                      $14     !2, !5
         21        ASSIGN_DIM                                               $14, !6
         22        OP_DATA                                                  ~20
   24    23      > JMP                                                      ->9
         24    >   FE_FREE                                                  $13
   23    25      > JMP                                                      ->6
         26    >   FE_FREE                                                  $10
   29    27      > RETURN                                                   !2
   32    28*     > RETURN                                                   null

End of function constructportrait

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.96 ms | 1407 KiB | 16 Q