3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<a href="http://www.mydomain.com/galeria/thumbnails.php?album=774" target="_blank"><img alt="/" src="http://img255.imageshack.us/img00/000/000001.png" height="133" width="113"></a>'; $doc = new DOMDocument; $doc->loadHTML( $html); $results = array(); foreach( $doc->getElementsByTagName( 'a') as $a) { // If there are no children, continue on if( !$a->hasChildNodes()) continue; // Find the child <img> tag, if it exists foreach( $a->childNodes as $child) { if( $child->nodeType == XML_ELEMENT_NODE && $child->tagName == 'img') { // Now we have the <a> tag in $a and the <img> tag in $child // Get the information we need: parse_str( parse_url( $a->getAttribute('href'), PHP_URL_QUERY), $a_params); $results[] = array( $a_params['album'], $child->getAttribute('src')); } } } var_dump( $results);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 50
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 50
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 48
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 48
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 47
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 47
Branch analysis from position: 27
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 48
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
filename:       /in/nLPL9
function name:  (null)
number of ops:  55
compiled vars:  !0 = $html, !1 = $doc, !2 = $results, !3 = $a, !4 = $child, !5 = $a_params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Ca+href%3D%22http%3A%2F%2Fwww.mydomain.com%2Fgaleria%2Fthumbnails.php%3Falbum%3D774%22+target%3D%22_blank%22%3E%3Cimg+alt%3D%22%2F%22+src%3D%22http%3A%2F%2Fimg255.imageshack.us%2Fimg00%2F000%2F000001.png%22+height%3D%22133%22+width%3D%22113%22%3E%3C%2Fa%3E'
    3     1        NEW                                              $7      'DOMDocument'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $7
    4     4        INIT_METHOD_CALL                                         !1, 'loadHTML'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
    5     7        ASSIGN                                                   !2, <array>
    6     8        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
          9        SEND_VAL_EX                                              'a'
         10        DO_FCALL                                      0  $12     
         11      > FE_RESET_R                                       $13     $12, ->50
         12    > > FE_FETCH_R                                               $13, !3, ->50
    8    13    >   INIT_METHOD_CALL                                         !3, 'hasChildNodes'
         14        DO_FCALL                                      0  $14     
         15        BOOL_NOT                                         ~15     $14
         16      > JMPZ                                                     ~15, ->18
         17    > > JMP                                                      ->12
   11    18    >   FETCH_OBJ_R                                      ~16     !3, 'childNodes'
         19      > FE_RESET_R                                       $17     ~16, ->48
         20    > > FE_FETCH_R                                               $17, !4, ->48
   12    21    >   FETCH_OBJ_R                                      ~18     !4, 'nodeType'
         22        IS_EQUAL                                         ~19     ~18, 1
         23      > JMPZ_EX                                          ~19     ~19, ->27
         24    >   FETCH_OBJ_R                                      ~20     !4, 'tagName'
         25        IS_EQUAL                                         ~21     ~20, 'img'
         26        BOOL                                             ~19     ~21
         27    > > JMPZ                                                     ~19, ->47
   15    28    >   INIT_FCALL                                               'parse_str'
         29        INIT_FCALL                                               'parse_url'
         30        INIT_METHOD_CALL                                         !3, 'getAttribute'
         31        SEND_VAL_EX                                              'href'
         32        DO_FCALL                                      0  $22     
         33        SEND_VAR                                                 $22
         34        SEND_VAL                                                 6
         35        DO_ICALL                                         $23     
         36        SEND_VAR                                                 $23
         37        SEND_REF                                                 !5
         38        DO_ICALL                                                 
   16    39        FETCH_DIM_R                                      ~26     !5, 'album'
         40        INIT_ARRAY                                       ~27     ~26
         41        INIT_METHOD_CALL                                         !4, 'getAttribute'
         42        SEND_VAL_EX                                              'src'
         43        DO_FCALL                                      0  $28     
         44        ADD_ARRAY_ELEMENT                                ~27     $28
         45        ASSIGN_DIM                                               !2
         46        OP_DATA                                                  ~27
   11    47    > > JMP                                                      ->20
         48    >   FE_FREE                                                  $17
    6    49      > JMP                                                      ->12
         50    >   FE_FREE                                                  $13
   20    51        INIT_FCALL                                               'var_dump'
         52        SEND_VAR                                                 !2
         53        DO_ICALL                                                 
         54      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.65 ms | 1400 KiB | 19 Q