3v4l.org

run code in 500+ PHP versions simultaneously
<?php $html = '<span class="ui_bubble_rating bubble_45"></span>'; $doc = new DOMDocument(); $doc->loadHTML($html); $xp = new DOMXPath($doc); $ratingsElements = $xp->query('//span[contains(concat(" ", normalize-space(@class), " "), " ui_bubble_rating ")]'); if ($ratingsElements->length > 0) { $firstRatingElement = $ratingsElements->item(0); if (preg_match('/(?<=\bbubble_)\d+/', $firstRatingElement->getAttribute('class'), $matches)) { echo $matches[0]; // 45 } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 33
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 33
filename:       /in/G0VM7
function name:  (null)
number of ops:  34
compiled vars:  !0 = $html, !1 = $doc, !2 = $xp, !3 = $ratingsElements, !4 = $firstRatingElement, !5 = $matches
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Cspan+class%3D%22ui_bubble_rating+bubble_45%22%3E%3C%2Fspan%3E'
    5     1        NEW                                                  $7      'DOMDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $7
    6     4        INIT_METHOD_CALL                                             !1, 'loadHTML'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
    7     7        NEW                                                  $11     'DOMXPath'
          8        SEND_VAR_EX                                                  !1
          9        DO_FCALL                                          0          
         10        ASSIGN                                                       !2, $11
    9    11        INIT_METHOD_CALL                                             !2, 'query'
         12        SEND_VAL_EX                                                  '%2F%2Fspan%5Bcontains%28concat%28%22+%22%2C+normalize-space%28%40class%29%2C+%22+%22%29%2C+%22+ui_bubble_rating+%22%29%5D'
         13        DO_FCALL                                          0  $14     
         14        ASSIGN                                                       !3, $14
   11    15        FETCH_OBJ_R                                          ~16     !3, 'length'
         16        IS_SMALLER                                                   0, ~16
         17      > JMPZ                                                         ~17, ->33
   12    18    >   INIT_METHOD_CALL                                             !3, 'item'
         19        SEND_VAL_EX                                                  0
         20        DO_FCALL                                          0  $18     
         21        ASSIGN                                                       !4, $18
   13    22        INIT_FCALL                                                   'preg_match'
         23        SEND_VAL                                                     '%2F%28%3F%3C%3D%5Cbbubble_%29%5Cd%2B%2F'
         24        INIT_METHOD_CALL                                             !4, 'getAttribute'
         25        SEND_VAL_EX                                                  'class'
         26        DO_FCALL                                          0  $20     
         27        SEND_VAR                                                     $20
         28        SEND_REF                                                     !5
         29        DO_ICALL                                             $21     
         30      > JMPZ                                                         $21, ->33
   14    31    >   FETCH_DIM_R                                          ~22     !5, 0
         32        ECHO                                                         ~22
   16    33    > > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.03 ms | 2083 KiB | 14 Q