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->childNodes 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){ $l = mb_strlen($searchString, "UTF-8"); $before = mb_substr($node->textContent, 0, $o); $wrap = mb_substr($node->textContent, $o, $l); $after = mb_substr($node->textContent, $o + $l); var_dump($before); var_dump($wrap); var_dump($after); } } } } }; foreach($words as $name => $word) $ps($D->documentElement, $word, $name); } $x = new DOMDocument(); $x->loadXML("<data>drugs cartel</data>"); applyHLToSiblings($x); var_dump($x);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DCi2c
function name:  (null)
number of ops:  13
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   NEW                                              $1      'DOMDocument'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   44     3        INIT_METHOD_CALL                                         !0, 'loadXML'
          4        SEND_VAL_EX                                              '%3Cdata%3Edrugs+cartel%3C%2Fdata%3E'
          5        DO_FCALL                                      0          
   45     6        INIT_FCALL                                               'applyhltosiblings'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0          
   46     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12      > 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/DCi2c
function name:  applyHLToSiblings
number of ops:  19
compiled vars:  !0 = $D, !1 = $words, !2 = $ps, !3 = $word, !4 = $name
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%2FDCi2c%3A16%240'
          4        BIND_LEXICAL                                             ~6, !0
          5        ASSIGN                                                   !2, ~6
   36     6      > FE_RESET_R                                       $8      !1, ->17
          7    > > FE_FETCH_R                                       ~9      $8, !3, ->17
          8    >   ASSIGN                                                   !4, ~9
   37     9        INIT_DYNAMIC_CALL                                        !2
         10        CHECK_FUNC_ARG                                           
         11        FETCH_OBJ_FUNC_ARG                               $11     !0, 'documentElement'
         12        SEND_FUNC_ARG                                            $11
         13        SEND_VAR_EX                                              !3
         14        SEND_VAR_EX                                              !4
         15        DO_FCALL                                      0          
   36    16      > JMP                                                      ->7
         17    >   FE_FREE                                                  $8
   40    18      > RETURN                                                   null

End of function applyhltosiblings

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

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.57 ms | 1407 KiB | 22 Q