3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = ' Here is some text and also: <figure class="class-one"> <img src="/example.jpg" alt="example alt" class="some-image-class"> <figcaption>example caption</figcaption> </figure> And another one (and many more): <figure class="class-one some-other-class"> <img src="/example2.jpg" alt="example2 alt"> </figure>'; $dom = new DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html); libxml_clear_errors(); $images = $dom->getElementsByTagName('img'); $figures = $dom->getElementsByTagName('figure'); $figures = array(); foreach ($figures as $figure) { $figures['class'] = $figure->getAttribute('class'); } print_r($figures);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/979qW
function name:  (null)
number of ops:  34
compiled vars:  !0 = $html, !1 = $dom, !2 = $images, !3 = $figures, !4 = $figure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '+Here+is+some+text+and+also%3A+%0A%3Cfigure+class%3D%22class-one%22%3E%0A++++%3Cimg+src%3D%22%2Fexample.jpg%22%0A+++++++++alt%3D%22example+alt%22%0A+++++++++class%3D%22some-image-class%22%3E%0A++++%3Cfigcaption%3Eexample+caption%3C%2Ffigcaption%3E%0A%3C%2Ffigure%3E%0A%0AAnd+another+one+%28and+many+more%29%3A+%0A%3Cfigure+class%3D%22class-one+some-other-class%22%3E%0A++++%3Cimg+src%3D%22%2Fexample2.jpg%22%0A+++++++++alt%3D%22example2+alt%22%3E%0A%3C%2Ffigure%3E'
   17     1        NEW                                              $6      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
   18     4        INIT_FCALL                                               'libxml_use_internal_errors'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                                 
   19     7        INIT_METHOD_CALL                                         !1, 'loadHTML'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   20    10        INIT_FCALL                                               'libxml_clear_errors'
         11        DO_ICALL                                                 
   22    12        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         13        SEND_VAL_EX                                              'img'
         14        DO_FCALL                                      0  $12     
         15        ASSIGN                                                   !2, $12
   23    16        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         17        SEND_VAL_EX                                              'figure'
         18        DO_FCALL                                      0  $14     
         19        ASSIGN                                                   !3, $14
   25    20        ASSIGN                                                   !3, <array>
   26    21      > FE_RESET_R                                       $17     !3, ->29
         22    > > FE_FETCH_R                                               $17, !4, ->29
   27    23    >   INIT_METHOD_CALL                                         !4, 'getAttribute'
         24        SEND_VAL_EX                                              'class'
         25        DO_FCALL                                      0  $19     
         26        ASSIGN_DIM                                               !3, 'class'
         27        OP_DATA                                                  $19
   26    28      > JMP                                                      ->22
         29    >   FE_FREE                                                  $17
   30    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.5 ms | 1405 KiB | 19 Q