3v4l.org

run code in 300+ PHP versions simultaneously
<?php $answers = array('0' => '1', '1' => '0', '2' => '3', '3' => '2', '4' => '1', '5' => '0'); // Name of result profiles $p1 = "Líder da turma"; $p2 = "Valente"; $p3 = "Atleta"; $p4 = "Paquerador"; $p5 = "Certinho"; $p6 = "Bagunceiro"; $p7 = "Desligado"; $p8 = "Tímido"; // Weights of the questions answers $a = array(array($p1, $p2), array($p1, $p5), array($p1, $p5), array($p8, $p7), array($p3, $p2), array($p3, $p4)); $b = array(array($p3, $p4), array($p6, $p3), array($p3, $p4), array($p6, $p2), array($p8, $p6), array($p8, $p7)); $c = array(array($p5, $p6), array($p8, $p4), array($p6, $p2), array($p1, $p5), array($p5, $p4), array($p2, $p6)); $d = array(array($p7, $p8), array($p2, $p7), array($p8, $p7), array($p3, $p4), array($p7, $p1), array($p5, $p1)); $arrayResults = array(); // Count the answers foreach ($answers as $key => $value) { echo $key; $questionNumber = $key; switch ($value) { case '0': $arrayResults[json_encode($a[$questionNumber][0])] += 1; $arrayResults[json_encode($a[$questionNumber][1])] += 1; break; case '1': $arrayResults[json_encode($b[$questionNumber][0])] += 1; $arrayResults[json_encode($b[$questionNumber][1])] += 1; break; case '2': $arrayResults[json_encode($c[$questionNumber][0])] += 1; $arrayResults[json_encode($c[$questionNumber][1])] += 1; break; case '3': $arrayResults[json_encode($d[$questionNumber][0])] += 1; $arrayResults[json_encode($d[$questionNumber][1])] += 1; break; } } // Get the profile with the max points $res = array_search(max($arrayResults), $arrayResults); echo json_encode($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 87, Position 2 = 161
Branch analysis from position: 87
2 jumps found. (Code = 78) Position 1 = 88, Position 2 = 161
Branch analysis from position: 88
2 jumps found. (Code = 44) Position 1 = 93, Position 2 = 100
Branch analysis from position: 93
2 jumps found. (Code = 44) Position 1 = 95, Position 2 = 115
Branch analysis from position: 95
2 jumps found. (Code = 44) Position 1 = 97, Position 2 = 130
Branch analysis from position: 97
2 jumps found. (Code = 44) Position 1 = 99, Position 2 = 145
Branch analysis from position: 99
1 jumps found. (Code = 42) Position 1 = 160
Branch analysis from position: 160
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
Branch analysis from position: 145
1 jumps found. (Code = 42) Position 1 = 160
Branch analysis from position: 160
Branch analysis from position: 130
1 jumps found. (Code = 42) Position 1 = 160
Branch analysis from position: 160
Branch analysis from position: 115
1 jumps found. (Code = 42) Position 1 = 160
Branch analysis from position: 160
Branch analysis from position: 100
1 jumps found. (Code = 42) Position 1 = 160
Branch analysis from position: 160
Branch analysis from position: 161
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 161
filename:       /in/5tWNj
function name:  (null)
number of ops:  175
compiled vars:  !0 = $answers, !1 = $p1, !2 = $p2, !3 = $p3, !4 = $p4, !5 = $p5, !6 = $p6, !7 = $p7, !8 = $p8, !9 = $a, !10 = $b, !11 = $c, !12 = $d, !13 = $arrayResults, !14 = $value, !15 = $key, !16 = $questionNumber, !17 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    6     1        ASSIGN                                                   !1, 'L%C3%ADder+da+turma'
    7     2        ASSIGN                                                   !2, 'Valente'
    8     3        ASSIGN                                                   !3, 'Atleta'
    9     4        ASSIGN                                                   !4, 'Paquerador'
   10     5        ASSIGN                                                   !5, 'Certinho'
   11     6        ASSIGN                                                   !6, 'Bagunceiro'
   12     7        ASSIGN                                                   !7, 'Desligado'
   13     8        ASSIGN                                                   !8, 'T%C3%ADmido'
   16     9        INIT_ARRAY                                       ~27     !1
         10        ADD_ARRAY_ELEMENT                                ~27     !2
         11        INIT_ARRAY                                       ~28     ~27
   17    12        INIT_ARRAY                                       ~29     !1
         13        ADD_ARRAY_ELEMENT                                ~29     !5
         14        ADD_ARRAY_ELEMENT                                ~28     ~29
   18    15        INIT_ARRAY                                       ~30     !1
         16        ADD_ARRAY_ELEMENT                                ~30     !5
         17        ADD_ARRAY_ELEMENT                                ~28     ~30
   19    18        INIT_ARRAY                                       ~31     !8
         19        ADD_ARRAY_ELEMENT                                ~31     !7
         20        ADD_ARRAY_ELEMENT                                ~28     ~31
   20    21        INIT_ARRAY                                       ~32     !3
         22        ADD_ARRAY_ELEMENT                                ~32     !2
         23        ADD_ARRAY_ELEMENT                                ~28     ~32
   21    24        INIT_ARRAY                                       ~33     !3
         25        ADD_ARRAY_ELEMENT                                ~33     !4
         26        ADD_ARRAY_ELEMENT                                ~28     ~33
   16    27        ASSIGN                                                   !9, ~28
   23    28        INIT_ARRAY                                       ~35     !3
         29        ADD_ARRAY_ELEMENT                                ~35     !4
         30        INIT_ARRAY                                       ~36     ~35
   24    31        INIT_ARRAY                                       ~37     !6
         32        ADD_ARRAY_ELEMENT                                ~37     !3
         33        ADD_ARRAY_ELEMENT                                ~36     ~37
   25    34        INIT_ARRAY                                       ~38     !3
         35        ADD_ARRAY_ELEMENT                                ~38     !4
         36        ADD_ARRAY_ELEMENT                                ~36     ~38
   26    37        INIT_ARRAY                                       ~39     !6
         38        ADD_ARRAY_ELEMENT                                ~39     !2
         39        ADD_ARRAY_ELEMENT                                ~36     ~39
   27    40        INIT_ARRAY                                       ~40     !8
         41        ADD_ARRAY_ELEMENT                                ~40     !6
         42        ADD_ARRAY_ELEMENT                                ~36     ~40
   28    43        INIT_ARRAY                                       ~41     !8
         44        ADD_ARRAY_ELEMENT                                ~41     !7
         45        ADD_ARRAY_ELEMENT                                ~36     ~41
   23    46        ASSIGN                                                   !10, ~36
   30    47        INIT_ARRAY                                       ~43     !5
         48        ADD_ARRAY_ELEMENT                                ~43     !6
         49        INIT_ARRAY                                       ~44     ~43
   31    50        INIT_ARRAY                                       ~45     !8
         51        ADD_ARRAY_ELEMENT                                ~45     !4
         52        ADD_ARRAY_ELEMENT                                ~44     ~45
   32    53        INIT_ARRAY                                       ~46     !6
         54        ADD_ARRAY_ELEMENT                                ~46     !2
         55        ADD_ARRAY_ELEMENT                                ~44     ~46
   33    56        INIT_ARRAY                                       ~47     !1
         57        ADD_ARRAY_ELEMENT                                ~47     !5
         58        ADD_ARRAY_ELEMENT                                ~44     ~47
   34    59        INIT_ARRAY                                       ~48     !5
         60        ADD_ARRAY_ELEMENT                                ~48     !4
         61        ADD_ARRAY_ELEMENT                                ~44     ~48
   35    62        INIT_ARRAY                                       ~49     !2
         63        ADD_ARRAY_ELEMENT                                ~49     !6
         64        ADD_ARRAY_ELEMENT                                ~44     ~49
   30    65        ASSIGN                                                   !11, ~44
   37    66        INIT_ARRAY                                       ~51     !7
         67        ADD_ARRAY_ELEMENT                                ~51     !8
         68        INIT_ARRAY                                       ~52     ~51
   38    69        INIT_ARRAY                                       ~53     !2
         70        ADD_ARRAY_ELEMENT                                ~53     !7
         71        ADD_ARRAY_ELEMENT                                ~52     ~53
   39    72        INIT_ARRAY                                       ~54     !8
         73        ADD_ARRAY_ELEMENT                                ~54     !7
         74        ADD_ARRAY_ELEMENT                                ~52     ~54
   40    75        INIT_ARRAY                                       ~55     !3
         76        ADD_ARRAY_ELEMENT                                ~55     !4
         77        ADD_ARRAY_ELEMENT                                ~52     ~55
   41    78        INIT_ARRAY                                       ~56     !7
         79        ADD_ARRAY_ELEMENT                                ~56     !1
         80        ADD_ARRAY_ELEMENT                                ~52     ~56
   42    81        INIT_ARRAY                                       ~57     !5
         82        ADD_ARRAY_ELEMENT                                ~57     !1
         83        ADD_ARRAY_ELEMENT                                ~52     ~57
   37    84        ASSIGN                                                   !12, ~52
   44    85        ASSIGN                                                   !13, <array>
   46    86      > FE_RESET_R                                       $60     !0, ->161
         87    > > FE_FETCH_R                                       ~61     $60, !14, ->161
         88    >   ASSIGN                                                   !15, ~61
   47    89        ECHO                                                     !15
   48    90        ASSIGN                                                   !16, !15
   50    91        IS_EQUAL                                                 !14, '0'
         92      > JMPNZ                                                    ~64, ->100
   54    93    >   IS_EQUAL                                                 !14, '1'
         94      > JMPNZ                                                    ~64, ->115
   58    95    >   IS_EQUAL                                                 !14, '2'
         96      > JMPNZ                                                    ~64, ->130
   62    97    >   IS_EQUAL                                                 !14, '3'
         98      > JMPNZ                                                    ~64, ->145
         99    > > JMP                                                      ->160
   51   100    >   INIT_FCALL                                               'json_encode'
        101        FETCH_DIM_R                                      ~65     !9, !16
        102        FETCH_DIM_R                                      ~66     ~65, 0
        103        SEND_VAL                                                 ~66
        104        DO_ICALL                                         $67     
        105        ASSIGN_DIM_OP                +=               1          !13, $67
        106        OP_DATA                                                  1
   52   107        INIT_FCALL                                               'json_encode'
        108        FETCH_DIM_R                                      ~69     !9, !16
        109        FETCH_DIM_R                                      ~70     ~69, 1
        110        SEND_VAL                                                 ~70
        111        DO_ICALL                                         $71     
        112        ASSIGN_DIM_OP                +=               1          !13, $71
        113        OP_DATA                                                  1
   53   114      > JMP                                                      ->160
   55   115    >   INIT_FCALL                                               'json_encode'
        116        FETCH_DIM_R                                      ~73     !10, !16
        117        FETCH_DIM_R                                      ~74     ~73, 0
        118        SEND_VAL                                                 ~74
        119        DO_ICALL                                         $75     
        120        ASSIGN_DIM_OP                +=               1          !13, $75
        121        OP_DATA                                                  1
   56   122        INIT_FCALL                                               'json_encode'
        123        FETCH_DIM_R                                      ~77     !10, !16
        124        FETCH_DIM_R                                      ~78     ~77, 1
        125        SEND_VAL                                                 ~78
        126        DO_ICALL                                         $79     
        127        ASSIGN_DIM_OP                +=               1          !13, $79
        128        OP_DATA                                                  1
   57   129      > JMP                                                      ->160
   59   130    >   INIT_FCALL                                               'json_encode'
        131        FETCH_DIM_R                                      ~81     !11, !16
        132        FETCH_DIM_R                                      ~82     ~81, 0
        133        SEND_VAL                                                 ~82
        134        DO_ICALL                                         $83     
        135        ASSIGN_DIM_OP                +=               1          !13, $83
        136        OP_DATA                                                  1
   60   137        INIT_FCALL                                               'json_encode'
        138        FETCH_DIM_R                                      ~85     !11, !16
        139        FETCH_DIM_R                                      ~86     ~85, 1
        140        SEND_VAL                                                 ~86
        141        DO_ICALL                                         $87     
        142        ASSIGN_DIM_OP                +=               1          !13, $87
        143        OP_DATA                                                  1
   61   144      > JMP                                                      ->160
   63   145    >   INIT_FCALL                                               'json_encode'
        146        FETCH_DIM_R                                      ~89     !12, !16
        147        FETCH_DIM_R                                      ~90     ~89, 0
        148        SEND_VAL                                                 ~90
        149        DO_ICALL                                         $91     
        150        ASSIGN_DIM_OP                +=               1          !13, $91
        151        OP_DATA                                                  1
   64   152        INIT_FCALL                                               'json_encode'
        153        FETCH_DIM_R                                      ~93     !12, !16
        154        FETCH_DIM_R                                      ~94     ~93, 1
        155        SEND_VAL                                                 ~94
        156        DO_ICALL                                         $95     
        157        ASSIGN_DIM_OP                +=               1          !13, $95
        158        OP_DATA                                                  1
   65   159      > JMP                                                      ->160
   46   160    > > JMP                                                      ->87
        161    >   FE_FREE                                                  $60
   69   162        INIT_FCALL                                               'array_search'
        163        INIT_FCALL                                               'max'
        164        SEND_VAR                                                 !13
        165        DO_ICALL                                         $97     
        166        SEND_VAR                                                 $97
        167        SEND_VAR                                                 !13
        168        DO_ICALL                                         $98     
        169        ASSIGN                                                   !17, $98
   70   170        INIT_FCALL                                               'json_encode'
        171        SEND_VAR                                                 !17
        172        DO_ICALL                                         $100    
        173        ECHO                                                     $100
        174      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.92 ms | 1408 KiB | 19 Q