3v4l.org

run code in 300+ PHP versions simultaneously
<?php class keywords { public $ngramsSpecific = array ( 'tos pačios lyties', 'seksualin* mažum*', 'gėj* eityn*' ); public $ngramsGeneric = array ( 'žmogaus teis*' ); public $keywordsSpecific = array ( 'gėjus', 'lesbietė', 'transvestitas', 'homoseksualas', 'biseksualas', 'homoseksualumas', 'homoseksualus', 'pride', 'LGBT', 'homofobija', 'homofobiškas', 'transseksualas', 'LGBTQ', 'DOMA', 'queer' ); public $keywordsGeneric = array ( 'tolerantiškas', 'tolerancija', 'diskriminacija', 'orientacija', 'paradas', 'eitynės', 'neapykanta', 'lygybė', 'mažuma' ); public $positiveAuthors = array ( 'Nida Vasiliauskaitė', 'Artūras Rudomanskis', 'Marija Aušrinė Pavilionienė', 'Mindaugas Kluonis', 'J. V. Daugmaudis' ); public $negativeAuthors = array ( 'Liudvika Pociūnienė', 'Tomas Čyvas', 'Vytautas Sinica', 'Paulius Stonis' ); } // this function checks the relevancy of an article function getRelevancy(article $article = null) { $keywords = new keywords(); //$articleBody = strtolower($article->body); $articleBody = "laba diena seksualinė mažuma yra labai geri, bet seksualinės mažumos nėra pats geriausias vaistas nuo visu ligu, nes seksualinėse mažumose gali buti pasitaike daugybe ivairiu dalyku tuo tarpu aseseksualinės mažumos nenori valgyto"; $match = array(); foreach($keywords->ngramsSpecific as $ngram) { //\b(seksualin\w+)\s\b(mazum\w+) $ngram = str_ireplace('*', '\w+', $ngram); $exploded = explode(" ", $ngram); foreach($exploded as &$piece) { $piece = "\b(" . $piece . ")"; } $regex = "/" . implode("\s", $exploded) . "/iu"; preg_match($regex, $articleBody, $matches); $match[] = $matches; } return $match; } print_r(getRelevancy());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G7ik6
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'getrelevancy'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
          5      > RETURN                                                   1

Function getrelevancy:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 42
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 42
Branch analysis from position: 9
2 jumps found. (Code = 125) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
2 jumps found. (Code = 126) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 26
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/G7ik6
function name:  getRelevancy
number of ops:  45
compiled vars:  !0 = $article, !1 = $keywords, !2 = $articleBody, !3 = $match, !4 = $ngram, !5 = $exploded, !6 = $piece, !7 = $regex, !8 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV_INIT                                        !0      null
   33     1        NEW                                              $9      'keywords'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $9
   35     4        ASSIGN                                                   !2, 'laba+diena+seksualin%C4%97+ma%C5%BEuma+yra+labai+geri%2C+bet+seksualin%C4%97s+ma%C5%BEumos+n%C4%97ra+pats+geriausias+vaistas+nuo+visu+ligu%2C+nes+seksualin%C4%97se+ma%C5%BEumose+gali+buti+pasitaike+daugybe+ivairiu+dalyku+tuo+tarpu+aseseksualin%C4%97s+ma%C5%BEumos+nenori+valgyto'
   36     5        ASSIGN                                                   !3, <array>
   37     6        FETCH_OBJ_R                                      ~14     !1, 'ngramsSpecific'
          7      > FE_RESET_R                                       $15     ~14, ->42
          8    > > FE_FETCH_R                                               $15, !4, ->42
   40     9    >   INIT_FCALL                                               'str_ireplace'
         10        SEND_VAL                                                 '%2A'
         11        SEND_VAL                                                 '%5Cw%2B'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $16     
         14        ASSIGN                                                   !4, $16
   41    15        INIT_FCALL                                               'explode'
         16        SEND_VAL                                                 '+'
         17        SEND_VAR                                                 !4
         18        DO_ICALL                                         $18     
         19        ASSIGN                                                   !5, $18
   42    20      > FE_RESET_RW                                      $20     !5, ->26
         21    > > FE_FETCH_RW                                              $20, !6, ->26
   44    22    >   CONCAT                                           ~21     '%5Cb%28', !6
         23        CONCAT                                           ~22     ~21, '%29'
         24        ASSIGN                                                   !6, ~22
   42    25      > JMP                                                      ->21
         26    >   FE_FREE                                                  $20
   46    27        INIT_FCALL                                               'implode'
         28        SEND_VAL                                                 '%5Cs'
         29        SEND_VAR                                                 !5
         30        DO_ICALL                                         $24     
         31        CONCAT                                           ~25     '%2F', $24
         32        CONCAT                                           ~26     ~25, '%2Fiu'
         33        ASSIGN                                                   !7, ~26
   48    34        INIT_FCALL                                               'preg_match'
         35        SEND_VAR                                                 !7
         36        SEND_VAR                                                 !2
         37        SEND_REF                                                 !8
         38        DO_ICALL                                                 
   49    39        ASSIGN_DIM                                               !3
         40        OP_DATA                                                  !8
   37    41      > JMP                                                      ->8
         42    >   FE_FREE                                                  $15
   51    43      > RETURN                                                   !3
   53    44*     > RETURN                                                   null

End of function getrelevancy

Class keywords: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
186.84 ms | 1402 KiB | 24 Q