3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html_string = '<img src="https://lh3.googleusercontent.com/D4r0FAqHl8HpymNXL78pSjskKl1f1WDU4jGIpTI0MiGR8xRfOCk5TiJH8dn9MdKEoyw=s100" srcset="https://lh3.googleusercontent.com/D4r0FAqHl8HpymNXL78pSjskKl1f1WDU4jGIpTI0MiGR8xRfOCk5TiJH8dn9MdKEoyw=s200 2x" class="T75of sHb2Xb" aria-hidden="true" alt="Kapak resmi" itemprop="image">'; //Create a new DOM document $doc = new \DOMDocument(); //Parse the HTML. $doc->loadHTML($html_string); //Get the image tag to parse $img = $doc->getElementsByTagName("img"); // DOMNodeList Object //Craete array to add all DOMElement value $image = array(); $i= 0; foreach($img as $item) { // DOMElement Object //DOMElement::getAttribute — Returns value of attribute $image[$i]['img']['src'] = $item->getAttribute('src'); $image[$i]['img']['srcset'] = $item->getAttribute('src'); $i++; } echo "<pre>"; print_r($image);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 31
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 31
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/19lIt
function name:  (null)
number of ops:  37
compiled vars:  !0 = $html_string, !1 = $doc, !2 = $img, !3 = $image, !4 = $i, !5 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cimg+src%3D%22https%3A%2F%2Flh3.googleusercontent.com%2FD4r0FAqHl8HpymNXL78pSjskKl1f1WDU4jGIpTI0MiGR8xRfOCk5TiJH8dn9MdKEoyw%3Ds100%22+srcset%3D%22https%3A%2F%2Flh3.googleusercontent.com%2FD4r0FAqHl8HpymNXL78pSjskKl1f1WDU4jGIpTI0MiGR8xRfOCk5TiJH8dn9MdKEoyw%3Ds200+2x%22+class%3D%22T75of+sHb2Xb%22+aria-hidden%3D%22true%22+alt%3D%22Kapak+resmi%22+itemprop%3D%22image%22%3E'
    5     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
    8     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   11     7        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                              'img'
          9        DO_FCALL                                      0  $11     
         10        ASSIGN                                                   !2, $11
   14    11        ASSIGN                                                   !3, <array>
   15    12        ASSIGN                                                   !4, 0
   16    13      > FE_RESET_R                                       $15     !2, ->31
         14    > > FE_FETCH_R                                               $15, !5, ->31
   18    15    >   INIT_METHOD_CALL                                         !5, 'getAttribute'
         16        SEND_VAL_EX                                              'src'
         17        DO_FCALL                                      0  $19     
         18        FETCH_DIM_W                                      $16     !3, !4
         19        FETCH_DIM_W                                      $17     $16, 'img'
         20        ASSIGN_DIM                                               $17, 'src'
         21        OP_DATA                                                  $19
   19    22        INIT_METHOD_CALL                                         !5, 'getAttribute'
         23        SEND_VAL_EX                                              'src'
         24        DO_FCALL                                      0  $23     
         25        FETCH_DIM_W                                      $20     !3, !4
         26        FETCH_DIM_W                                      $21     $20, 'img'
         27        ASSIGN_DIM                                               $21, 'srcset'
         28        OP_DATA                                                  $23
   20    29        PRE_INC                                                  !4
   16    30      > JMP                                                      ->14
         31    >   FE_FREE                                                  $15
   24    32        ECHO                                                     '%3Cpre%3E'
   25    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
244.59 ms | 1007 KiB | 14 Q