3v4l.org

run code in 300+ PHP versions simultaneously
<?php $hostname = "lekkere.koekjes.men"; $certificates = json_decode('[{"commonName":"*.men"},{"commonName":"*.hans.nl"},{"commonName":"*.koekjes.men"}]'); $hostnameParts = explode(".", $hostname); foreach ($certificates as $certificate) { // commonName = *.lekkere.koekjes.men // hostname = www.lekkere.koekjes.men $commonName = $certificate->commonName; $commonNameParts = explode(".", $commonName); for ($i = 0; $i < max(count($commonNameParts), count($hostnameParts)); $i++) { $commonNamePart = count($commonNameParts) > ($i + 1) ? $commonNameParts[count($commonNameParts) - $i - 1] : null; $hostnamePart = count($hostnameParts) > ($i + 1) ? $hostnameParts[count($hostnameParts) - $i - 1] : null; if (! ( $commonNamePart === '*' || ($commonNamePart === null && $hostnamePart === 'www' && !in_array("*", $commonNameParts)) || ($commonNamePart === $hostnamePart) ) ) { continue 2; } } var_dump($certificate); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 78
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 78
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 21
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 31
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 43
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 47) Position 1 = 47, Position 2 = 59
Branch analysis from position: 47
2 jumps found. (Code = 46) Position 1 = 49, Position 2 = 51
Branch analysis from position: 49
2 jumps found. (Code = 46) Position 1 = 52, Position 2 = 58
Branch analysis from position: 52
2 jumps found. (Code = 47) Position 1 = 60, Position 2 = 62
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 65
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 65
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 21
Branch analysis from position: 74
Branch analysis from position: 21
Branch analysis from position: 62
Branch analysis from position: 58
Branch analysis from position: 51
Branch analysis from position: 59
Branch analysis from position: 43
2 jumps found. (Code = 47) Position 1 = 47, Position 2 = 59
Branch analysis from position: 47
Branch analysis from position: 59
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 43
Branch analysis from position: 37
Branch analysis from position: 43
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
filename:       /in/Ziqkv
function name:  (null)
number of ops:  80
compiled vars:  !0 = $hostname, !1 = $certificates, !2 = $hostnameParts, !3 = $certificate, !4 = $commonName, !5 = $commonNameParts, !6 = $i, !7 = $commonNamePart, !8 = $hostnamePart
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'lekkere.koekjes.men'
    4     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAL                                                 '%5B%7B%22commonName%22%3A%22%2A.men%22%7D%2C%7B%22commonName%22%3A%22%2A.hans.nl%22%7D%2C%7B%22commonName%22%3A%22%2A.koekjes.men%22%7D%5D'
          3        DO_ICALL                                         $10     
          4        ASSIGN                                                   !1, $10
    6     5        INIT_FCALL                                               'explode'
          6        SEND_VAL                                                 '.'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $12     
          9        ASSIGN                                                   !2, $12
    7    10      > FE_RESET_R                                       $14     !1, ->78
         11    > > FE_FETCH_R                                               $14, !3, ->78
   10    12    >   FETCH_OBJ_R                                      ~15     !3, 'commonName'
         13        ASSIGN                                                   !4, ~15
   11    14        INIT_FCALL                                               'explode'
         15        SEND_VAL                                                 '.'
         16        SEND_VAR                                                 !4
         17        DO_ICALL                                         $17     
         18        ASSIGN                                                   !5, $17
   13    19        ASSIGN                                                   !6, 0
         20      > JMP                                                      ->66
   14    21    >   COUNT                                            ~20     !5
         22        ADD                                              ~21     !6, 1
         23        IS_SMALLER                                               ~21, ~20
         24      > JMPZ                                                     ~22, ->31
         25    >   COUNT                                            ~23     !5
         26        SUB                                              ~24     ~23, !6
         27        SUB                                              ~25     ~24, 1
         28        FETCH_DIM_R                                      ~26     !5, ~25
         29        QM_ASSIGN                                        ~27     ~26
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~27     null
         32    >   ASSIGN                                                   !7, ~27
   15    33        COUNT                                            ~29     !2
         34        ADD                                              ~30     !6, 1
         35        IS_SMALLER                                               ~30, ~29
         36      > JMPZ                                                     ~31, ->43
         37    >   COUNT                                            ~32     !2
         38        SUB                                              ~33     ~32, !6
         39        SUB                                              ~34     ~33, 1
         40        FETCH_DIM_R                                      ~35     !2, ~34
         41        QM_ASSIGN                                        ~36     ~35
         42      > JMP                                                      ->44
         43    >   QM_ASSIGN                                        ~36     null
         44    >   ASSIGN                                                   !8, ~36
   18    45        IS_IDENTICAL                                     ~38     !7, '%2A'
         46      > JMPNZ_EX                                         ~38     ~38, ->59
   20    47    >   TYPE_CHECK                                    2  ~39     !7
         48      > JMPZ_EX                                          ~39     ~39, ->51
         49    >   IS_IDENTICAL                                     ~40     !8, 'www'
         50        BOOL                                             ~39     ~40
         51    > > JMPZ_EX                                          ~39     ~39, ->58
         52    >   INIT_FCALL                                               'in_array'
         53        SEND_VAL                                                 '%2A'
         54        SEND_VAR                                                 !5
         55        DO_ICALL                                         $41     
         56        BOOL_NOT                                         ~42     $41
         57        BOOL                                             ~39     ~42
         58    >   BOOL                                             ~38     ~39
         59    > > JMPNZ_EX                                         ~38     ~38, ->62
   22    60    >   IS_IDENTICAL                                     ~43     !7, !8
         61        BOOL                                             ~38     ~43
         62    >   BOOL_NOT                                         ~44     ~38
         63      > JMPZ                                                     ~44, ->65
   25    64    > > JMP                                                      ->11
   13    65    >   PRE_INC                                                  !6
         66    >   INIT_FCALL                                               'max'
         67        COUNT                                            ~46     !5
         68        SEND_VAL                                                 ~46
         69        COUNT                                            ~47     !2
         70        SEND_VAL                                                 ~47
         71        DO_ICALL                                         $48     
         72        IS_SMALLER                                               !6, $48
         73      > JMPNZ                                                    ~49, ->21
   29    74    >   INIT_FCALL                                               'var_dump'
         75        SEND_VAR                                                 !3
         76        DO_ICALL                                                 
    7    77      > JMP                                                      ->11
         78    >   FE_FREE                                                  $14
   30    79      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.04 ms | 1404 KiB | 23 Q