3v4l.org

run code in 300+ PHP versions simultaneously
<?php function applyHLToSiblings(DOMDocument $D){ $words[0] = "cart"; /* $words[1] = "car"; $words[2] = "cartel"; $words[3] = "art"; $words[4] = "drug"; $words[5] = "drugs"; $words[6] = "rug"; $words[7] = "rugs"; */ $ps = function($siblingsContainer, $searchString, $name) use($D){ foreach($siblingsContainer->getChildNodes() as $node){ if($node instanceof DOMText){ if(mb_strlen($node->textContent, "UTF-8") >= mb_strlen($searchString)){ $o = mb_strpos($node->textContent, $searchString); if($o !== false){ $before = mb_substr($node->textContent, 0, $o); $wrap = mb_substr($node->textContent, $o, mb_strlen($searchString, "UTF-8")); $after = mb_substr($node->textContent, $o); print_r($before); print_r($wrap); print_r($after); } } } } }; foreach($words as $name => $word) $ps($container->documentNode, $word, $name); } $x = new DOMDocument(); $x->loadXML("<data>drugs cartel</data>"); applyHLToSiblings($x);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/24cAU
function name:  (null)
number of ops:  10
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   NEW                                              $1      'DOMDocument'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   43     3        INIT_METHOD_CALL                                         !0, 'loadXML'
          4        SEND_VAL_EX                                              '%3Cdata%3Edrugs+cartel%3C%2Fdata%3E'
          5        DO_FCALL                                      0          
   44     6        INIT_FCALL                                               'applyhltosiblings'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0          
          9      > RETURN                                                   1

Function applyhltosiblings:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/24cAU
function name:  applyHLToSiblings
number of ops:  19
compiled vars:  !0 = $D, !1 = $words, !2 = $ps, !3 = $word, !4 = $name, !5 = $container
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN_DIM                                               !1, 0
          2        OP_DATA                                                  'cart'
   16     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F24cAU%3A16%240'
          4        BIND_LEXICAL                                             ~7, !0
          5        ASSIGN                                                   !2, ~7
   35     6      > FE_RESET_R                                       $9      !1, ->17
          7    > > FE_FETCH_R                                       ~10     $9, !3, ->17
          8    >   ASSIGN                                                   !4, ~10
   36     9        INIT_DYNAMIC_CALL                                        !2
         10        CHECK_FUNC_ARG                                           
         11        FETCH_OBJ_FUNC_ARG                               $12     !5, 'documentNode'
         12        SEND_FUNC_ARG                                            $12
         13        SEND_VAR_EX                                              !3
         14        SEND_VAR_EX                                              !4
         15        DO_FCALL                                      0          
   35    16      > JMP                                                      ->7
         17    >   FE_FREE                                                  $9
   39    18      > RETURN                                                   null

End of function applyhltosiblings

Function %00%7Bclosure%7D%2Fin%2F24cAU%3A16%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 62
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 62
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 61
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 61
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 61
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 61
Branch analysis from position: 61
Branch analysis from position: 61
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 62
filename:       /in/24cAU
function name:  {closure}
number of ops:  64
compiled vars:  !0 = $siblingsContainer, !1 = $searchString, !2 = $name, !3 = $D, !4 = $node, !5 = $o, !6 = $before, !7 = $wrap, !8 = $after
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        BIND_STATIC                                              !3
   17     4        INIT_METHOD_CALL                                         !0, 'getChildNodes'
          5        DO_FCALL                                      0  $9      
          6      > FE_RESET_R                                       $10     $9, ->62
          7    > > FE_FETCH_R                                               $10, !4, ->62
   18     8    >   INSTANCEOF                                               !4, 'DOMText'
          9      > JMPZ                                                     ~11, ->61
   19    10    >   INIT_FCALL                                               'mb_strlen'
         11        FETCH_OBJ_R                                      ~12     !4, 'textContent'
         12        SEND_VAL                                                 ~12
         13        SEND_VAL                                                 'UTF-8'
         14        DO_ICALL                                         $13     
         15        INIT_FCALL                                               'mb_strlen'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $14     
         18        IS_SMALLER_OR_EQUAL                                      $14, $13
         19      > JMPZ                                                     ~15, ->61
   20    20    >   INIT_FCALL                                               'mb_strpos'
         21        FETCH_OBJ_R                                      ~16     !4, 'textContent'
         22        SEND_VAL                                                 ~16
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $17     
         25        ASSIGN                                                   !5, $17
   21    26        TYPE_CHECK                                  1018          !5
         27      > JMPZ                                                     ~19, ->61
   22    28    >   INIT_FCALL                                               'mb_substr'
         29        FETCH_OBJ_R                                      ~20     !4, 'textContent'
         30        SEND_VAL                                                 ~20
         31        SEND_VAL                                                 0
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                         $21     
         34        ASSIGN                                                   !6, $21
   23    35        INIT_FCALL                                               'mb_substr'
         36        FETCH_OBJ_R                                      ~23     !4, 'textContent'
         37        SEND_VAL                                                 ~23
         38        SEND_VAR                                                 !5
         39        INIT_FCALL                                               'mb_strlen'
         40        SEND_VAR                                                 !1
         41        SEND_VAL                                                 'UTF-8'
         42        DO_ICALL                                         $24     
         43        SEND_VAR                                                 $24
         44        DO_ICALL                                         $25     
         45        ASSIGN                                                   !7, $25
   24    46        INIT_FCALL                                               'mb_substr'
         47        FETCH_OBJ_R                                      ~27     !4, 'textContent'
         48        SEND_VAL                                                 ~27
         49        SEND_VAR                                                 !5
         50        DO_ICALL                                         $28     
         51        ASSIGN                                                   !8, $28
   26    52        INIT_FCALL                                               'print_r'
         53        SEND_VAR                                                 !6
         54        DO_ICALL                                                 
   27    55        INIT_FCALL                                               'print_r'
         56        SEND_VAR                                                 !7
         57        DO_ICALL                                                 
   28    58        INIT_FCALL                                               'print_r'
         59        SEND_VAR                                                 !8
         60        DO_ICALL                                                 
   17    61    > > JMP                                                      ->7
         62    >   FE_FREE                                                  $10
   33    63      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F24cAU%3A16%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.55 ms | 1407 KiB | 22 Q