3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <span>0 Dollar</span> <span>0.01 Dollar</span> <span>0.00 Dollar</span> <span>50.00 Dollar</span> HTML; $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xp = new DOMXPath($dom); $xp->registerNamespace("php", "http://php.net/xpath"); $xp->registerPHPFunctions('preg_match'); $pattern = '/\A(?=[0.]*[1-9])\d+(?:\.\d+)?+\h+Dollar\z/'; $spans = $xp->query("//span[php:functionString('preg_match', '$pattern', text())>0]"); foreach ($spans as $span) { echo $span->nodeValue . PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 33
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 33
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/saAPi
function name:  (null)
number of ops:  35
compiled vars:  !0 = $html, !1 = $dom, !2 = $xp, !3 = $pattern, !4 = $spans, !5 = $span
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Cspan%3E0+Dollar%3C%2Fspan%3E%0A%3Cspan%3E0.01+Dollar%3C%2Fspan%3E%0A%3Cspan%3E0.00+Dollar%3C%2Fspan%3E%0A%3Cspan%3E50.00+Dollar%3C%2Fspan%3E'
   10     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
   11     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              8196
          7        DO_FCALL                                      0          
   13     8        NEW                                              $11     'DOMXPath'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $11
   14    12        INIT_METHOD_CALL                                         !2, 'registerNamespace'
         13        SEND_VAL_EX                                              'php'
         14        SEND_VAL_EX                                              'http%3A%2F%2Fphp.net%2Fxpath'
         15        DO_FCALL                                      0          
   15    16        INIT_METHOD_CALL                                         !2, 'registerPHPFunctions'
         17        SEND_VAL_EX                                              'preg_match'
         18        DO_FCALL                                      0          
   16    19        ASSIGN                                                   !3, '%2F%5CA%28%3F%3D%5B0.%5D%2A%5B1-9%5D%29%5Cd%2B%28%3F%3A%5C.%5Cd%2B%29%3F%2B%5Ch%2BDollar%5Cz%2F'
   17    20        INIT_METHOD_CALL                                         !2, 'query'
         21        ROPE_INIT                                     3  ~18     '%2F%2Fspan%5Bphp%3AfunctionString%28%27preg_match%27%2C+%27'
         22        ROPE_ADD                                      1  ~18     ~18, !3
         23        ROPE_END                                      2  ~17     ~18, '%27%2C+text%28%29%29%3E0%5D'
         24        SEND_VAL_EX                                              ~17
         25        DO_FCALL                                      0  $20     
         26        ASSIGN                                                   !4, $20
   19    27      > FE_RESET_R                                       $22     !4, ->33
         28    > > FE_FETCH_R                                               $22, !5, ->33
   20    29    >   FETCH_OBJ_R                                      ~23     !5, 'nodeValue'
         30        CONCAT                                           ~24     ~23, '%0A'
         31        ECHO                                                     ~24
   19    32      > JMP                                                      ->28
         33    >   FE_FREE                                                  $22
   21    34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.1 ms | 1000 KiB | 13 Q