3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '<span class=" xx email_p_14 xx "> labore@et.de </span>'; $dom = new DomDocument(); $dom->loadHTML($str, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $doc = new DOMXPath($dom); $items = $doc->query("//span[contains(@class, 'email_')]"); foreach ($items as $item) { $class = array_filter(explode(' ', $item->getAttribute('class')), function($x) { return substr( $x, 0, 6 ) === "email_"; }); print_r($class); echo $item->nodeValue; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 37
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 37
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/LTAgk
function name:  (null)
number of ops:  39
compiled vars:  !0 = $str, !1 = $dom, !2 = $doc, !3 = $items, !4 = $item, !5 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cspan+class%3D%22+xx+email_p_14+xx+%22%3E+labore%40et.de+%3C%2Fspan%3E'
    4     1        NEW                                              $7      'DomDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
    5     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
    6     8        NEW                                              $11     'DOMXPath'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $11
    8    12        INIT_METHOD_CALL                                         !2, 'query'
         13        SEND_VAL_EX                                              '%2F%2Fspan%5Bcontains%28%40class%2C+%27email_%27%29%5D'
         14        DO_FCALL                                      0  $14     
         15        ASSIGN                                                   !3, $14
   10    16      > FE_RESET_R                                       $16     !3, ->37
         17    > > FE_FETCH_R                                               $16, !4, ->37
   11    18    >   INIT_FCALL                                               'array_filter'
         19        INIT_FCALL                                               'explode'
         20        SEND_VAL                                                 '+'
         21        INIT_METHOD_CALL                                         !4, 'getAttribute'
         22        SEND_VAL_EX                                              'class'
         23        DO_FCALL                                      0  $17     
         24        SEND_VAR                                                 $17
         25        DO_ICALL                                         $18     
         26        SEND_VAR                                                 $18
         27        DECLARE_LAMBDA_FUNCTION                          ~19     [0]
   13    28        SEND_VAL                                                 ~19
   11    29        DO_ICALL                                         $20     
         30        ASSIGN                                                   !5, $20
   14    31        INIT_FCALL                                               'print_r'
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                                 
   15    34        FETCH_OBJ_R                                      ~23     !4, 'nodeValue'
         35        ECHO                                                     ~23
   10    36      > JMP                                                      ->17
         37    >   FE_FREE                                                  $16
   16    38      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LTAgk
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'substr'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 6
          5        DO_ICALL                                         $1      
          6        IS_IDENTICAL                                     ~2      $1, 'email_'
          7      > RETURN                                                   ~2
   13     8*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.47 ms | 1018 KiB | 17 Q