3v4l.org

run code in 300+ PHP versions simultaneously
<?php $desc = '<p> <span style="font-size:12pt;"><strong>Nappe bouton power Samsung Galaxy S6 Edge G925F</strong></span> <br> <span style="font-size:12pt;"><u><i title="bouton power">Nappe Bouton poweR, compatible Samsung Galaxy S6 Edge G925F.</i></u></span> </p>'; canLinkThisWordIn('bouton Power', $desc); function canLinkThisWordIn($word, $html){ $forbidenTagsArray = array('strong', 'a', 'b', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'); $dom = new DOMDocument(); $dom->loadHTML($html); $xpath = new DOMXpath($dom); $wordTags = $xpath->query("//*[text()[contains(translate(., '".strtoupper($word)."', '".strtolower($word)."'), '".strtolower($word)."')]]"); foreach($wordTags as $wordTag){ if(checkTagAndParent($wordTag, $forbidenTagsArray)){ echo "\n".$wordTag->nodeName." == ".$wordTag->nodeValue; } } return false; } function checkTagAndParent($tag, $forbiden){ if(!in_array($tag->tagName, $forbiden)){ if($tag->parentNode){ $parentTags = array_filter(explode("/", preg_replace("/\[[^]]+\]/", "", $tag->getNodePath()))); foreach($parentTags as $parentTag){ if(in_array($parentTag, $forbiden)){ return false; } } } return true; } return false; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pNsv9
function name:  (null)
number of ops:  6
compiled vars:  !0 = $desc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cp%3E%0A%3Cspan+style%3D%22font-size%3A12pt%3B%22%3E%3Cstrong%3ENappe+bouton+power+Samsung+Galaxy+S6+Edge+G925F%3C%2Fstrong%3E%3C%2Fspan%3E%0A%3Cbr%3E%0A%3Cspan+style%3D%22font-size%3A12pt%3B%22%3E%3Cu%3E%3Ci+title%3D%22bouton+power%22%3ENappe+Bouton+poweR%2C+compatible+Samsung+Galaxy+S6+Edge+G925F.%3C%2Fi%3E%3C%2Fu%3E%3C%2Fspan%3E%0A%3C%2Fp%3E'
    8     1        INIT_FCALL_BY_NAME                                       'canLinkThisWordIn'
          2        SEND_VAL_EX                                              'bouton+Power'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   38     5      > RETURN                                                   1

Function canlinkthiswordin:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 46
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 46
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 45
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 45
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
filename:       /in/pNsv9
function name:  canLinkThisWordIn
number of ops:  49
compiled vars:  !0 = $word, !1 = $html, !2 = $forbidenTagsArray, !3 = $dom, !4 = $xpath, !5 = $wordTags, !6 = $wordTag
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        ASSIGN                                                   !2, <array>
   14     3        NEW                                              $8      'DOMDocument'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !3, $8
          6        INIT_METHOD_CALL                                         !3, 'loadHTML'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
          9        NEW                                              $12     'DOMXpath'
         10        SEND_VAR_EX                                              !3
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !4, $12
   15    13        INIT_METHOD_CALL                                         !4, 'query'
         14        INIT_FCALL                                               'strtoupper'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $15     
         17        CONCAT                                           ~16     '%2F%2F%2A%5Btext%28%29%5Bcontains%28translate%28.%2C+%27', $15
         18        CONCAT                                           ~17     ~16, '%27%2C+%27'
         19        INIT_FCALL                                               'strtolower'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $18     
         22        CONCAT                                           ~19     ~17, $18
         23        CONCAT                                           ~20     ~19, '%27%29%2C+%27'
         24        INIT_FCALL                                               'strtolower'
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $21     
         27        CONCAT                                           ~22     ~20, $21
         28        CONCAT                                           ~23     ~22, '%27%29%5D%5D'
         29        SEND_VAL_EX                                              ~23
         30        DO_FCALL                                      0  $24     
         31        ASSIGN                                                   !5, $24
   17    32      > FE_RESET_R                                       $26     !5, ->46
         33    > > FE_FETCH_R                                               $26, !6, ->46
   18    34    >   INIT_FCALL_BY_NAME                                       'checkTagAndParent'
         35        SEND_VAR_EX                                              !6
         36        SEND_VAR_EX                                              !2
         37        DO_FCALL                                      0  $27     
         38      > JMPZ                                                     $27, ->45
   19    39    >   FETCH_OBJ_R                                      ~28     !6, 'nodeName'
         40        CONCAT                                           ~29     '%0A', ~28
         41        CONCAT                                           ~30     ~29, '+%3D%3D+'
         42        FETCH_OBJ_R                                      ~31     !6, 'nodeValue'
         43        CONCAT                                           ~32     ~30, ~31
         44        ECHO                                                     ~32
   17    45    > > JMP                                                      ->33
         46    >   FE_FREE                                                  $26
   22    47      > RETURN                                                   <false>
   23    48*     > RETURN                                                   null

End of function canlinkthiswordin

Function checktagandparent:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 38
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 37
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 36
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 36
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 37
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pNsv9
function name:  checkTagAndParent
number of ops:  40
compiled vars:  !0 = $tag, !1 = $forbiden, !2 = $parentTags, !3 = $parentTag
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        INIT_FCALL                                               'in_array'
          3        FETCH_OBJ_R                                      ~4      !0, 'tagName'
          4        SEND_VAL                                                 ~4
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $5      
          7        BOOL_NOT                                         ~6      $5
          8      > JMPZ                                                     ~6, ->38
   27     9    >   FETCH_OBJ_R                                      ~7      !0, 'parentNode'
         10      > JMPZ                                                     ~7, ->37
   28    11    >   INIT_FCALL                                               'array_filter'
         12        INIT_FCALL                                               'explode'
         13        SEND_VAL                                                 '%2F'
         14        INIT_FCALL                                               'preg_replace'
         15        SEND_VAL                                                 '%2F%5C%5B%5B%5E%5D%5D%2B%5C%5D%2F'
         16        SEND_VAL                                                 ''
         17        INIT_METHOD_CALL                                         !0, 'getNodePath'
         18        DO_FCALL                                      0  $8      
         19        SEND_VAR                                                 $8
         20        DO_ICALL                                         $9      
         21        SEND_VAR                                                 $9
         22        DO_ICALL                                         $10     
         23        SEND_VAR                                                 $10
         24        DO_ICALL                                         $11     
         25        ASSIGN                                                   !2, $11
   29    26      > FE_RESET_R                                       $13     !2, ->36
         27    > > FE_FETCH_R                                               $13, !3, ->36
   30    28    >   INIT_FCALL                                               'in_array'
         29        SEND_VAR                                                 !3
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $14     
         32      > JMPZ                                                     $14, ->35
   31    33    >   FE_FREE                                                  $13
         34      > RETURN                                                   <false>
   29    35    > > JMP                                                      ->27
         36    >   FE_FREE                                                  $13
   35    37    > > RETURN                                                   <true>
   37    38    > > RETURN                                                   <false>
   38    39*     > RETURN                                                   null

End of function checktagandparent

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.64 ms | 1404 KiB | 25 Q