3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = ' <span class="phone-number" data-id="999" style="{lots of random stuff here}">+61 9900 0000</span> <span class="email" data-something="xxx" style="{lots of random stuff here}">test@test.com</span> '; $dom = new DOMDocument; $dom->loadHtml($html); $xpath = new DOMXPath($dom); $phone = $xpath->query("//span[contains(@class, 'phone-number')]"); $email = $xpath->query("//span[contains(@class, 'email')]"); echo $phone->item(0)->nodeValue.PHP_EOL; echo $email->item(0)->nodeValue.PHP_EOL; /* foreach ($phone as $value) { echo $value->nodeValue; } */
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qbVaS
function name:  (null)
number of ops:  32
compiled vars:  !0 = $html, !1 = $dom, !2 = $xpath, !3 = $phone, !4 = $email
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%0A%3Cspan+class%3D%22phone-number%22+data-id%3D%22999%22+style%3D%22%7Blots+of+random+stuff+here%7D%22%3E%2B61+9900+0000%3C%2Fspan%3E%0A%3Cspan+class%3D%22email%22+data-something%3D%22xxx%22+style%3D%22%7Blots+of+random+stuff+here%7D%22%3Etest%40test.com%3C%2Fspan%3E%0A'
    7     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
    8     4        INIT_METHOD_CALL                                         !1, 'loadHtml'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   10     7        NEW                                              $10     'DOMXPath'
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !2, $10
   12    11        INIT_METHOD_CALL                                         !2, 'query'
         12        SEND_VAL_EX                                              '%2F%2Fspan%5Bcontains%28%40class%2C+%27phone-number%27%29%5D'
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !3, $13
   13    15        INIT_METHOD_CALL                                         !2, 'query'
         16        SEND_VAL_EX                                              '%2F%2Fspan%5Bcontains%28%40class%2C+%27email%27%29%5D'
         17        DO_FCALL                                      0  $15     
         18        ASSIGN                                                   !4, $15
   15    19        INIT_METHOD_CALL                                         !3, 'item'
         20        SEND_VAL_EX                                              0
         21        DO_FCALL                                      0  $17     
         22        FETCH_OBJ_R                                      ~18     $17, 'nodeValue'
         23        CONCAT                                           ~19     ~18, '%0A'
         24        ECHO                                                     ~19
   16    25        INIT_METHOD_CALL                                         !4, 'item'
         26        SEND_VAL_EX                                              0
         27        DO_FCALL                                      0  $20     
         28        FETCH_OBJ_R                                      ~21     $20, 'nodeValue'
         29        CONCAT                                           ~22     ~21, '%0A'
         30        ECHO                                                     ~22
   22    31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.71 ms | 996 KiB | 13 Q