3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Ingreso $html = ' <img class="img" src="ejemplo1.jpg"> <img width="72" height="72" alt="" class="bo img" src="https://scontent-mia3-2.xx.fbcdn.net/v/t1.0-1/cp0/e15/q65/p74x74/21151613_1725782907724134_7535903357386699205_n.jpg?efg=eyJpIjoiYiJ9&amp;oh=4f22a577f965566b2016ef842f5b110f&amp;oe=5A1DE043"> <img class="bo etc" src="ejemplo2.jpg"> <img class="bo etc img" src="ejemplo3.jpg"> '; //Englobamos en body para corregirlo y que lo procese bien $html = "<body>$html</body>"; //Generar el DOM $dom = new DOMDocument; $dom->loadHTML($html, LIBXML_COMPACT | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_HTML_NODEFDTD); //Obtener todas las imágenes $img_nodelist = $dom->getElementsByTagName('img'); //Recorrer cada una foreach ($img_nodelist as $img) { //Obtener la lista de clases $clases = $img->getAttribute('class'); $clases_arr = explode(' ', $clases); //Ver si contiene ambas clases $clases_buscadas = array('bo', 'img'); if (!array_diff($clases_buscadas, $clases_arr)) { //Contiene las clases //Obtener el SRC $urlImagen = $img->getAttribute('src'); echo "URL: $urlImagen\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 43
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 43
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 42
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 42
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
filename:       /in/OYNce
function name:  (null)
number of ops:  45
compiled vars:  !0 = $html, !1 = $dom, !2 = $img_nodelist, !3 = $img, !4 = $clases, !5 = $clases_arr, !6 = $clases_buscadas, !7 = $urlImagen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '%0A++++%3Cimg+class%3D%22img%22+src%3D%22ejemplo1.jpg%22%3E%0A++++%3Cimg+width%3D%2272%22+height%3D%2272%22+alt%3D%22%22+class%3D%22bo+img%22+src%3D%22https%3A%2F%2Fscontent-mia3-2.xx.fbcdn.net%2Fv%2Ft1.0-1%2Fcp0%2Fe15%2Fq65%2Fp74x74%2F21151613_1725782907724134_7535903357386699205_n.jpg%3Fefg%3DeyJpIjoiYiJ9%26amp%3Boh%3D4f22a577f965566b2016ef842f5b110f%26amp%3Boe%3D5A1DE043%22%3E%0A++++%3Cimg+class%3D%22bo+etc%22+src%3D%22ejemplo2.jpg%22%3E%0A++++%3Cimg+class%3D%22bo+etc+img%22+src%3D%22ejemplo3.jpg%22%3E%0A'
   13     1        ROPE_INIT                                     3  ~10     '%3Cbody%3E'
          2        ROPE_ADD                                      1  ~10     ~10, !0
          3        ROPE_END                                      2  ~9      ~10, '%3C%2Fbody%3E'
          4        ASSIGN                                                   !0, ~9
   16     5        NEW                                              $13     'DOMDocument'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $13
   17     8        INIT_METHOD_CALL                                         !1, 'loadHTML'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAL_EX                                              75780
         11        DO_FCALL                                      0          
   21    12        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         13        SEND_VAL_EX                                              'img'
         14        DO_FCALL                                      0  $17     
         15        ASSIGN                                                   !2, $17
   24    16      > FE_RESET_R                                       $19     !2, ->43
         17    > > FE_FETCH_R                                               $19, !3, ->43
   26    18    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         19        SEND_VAL_EX                                              'class'
         20        DO_FCALL                                      0  $20     
         21        ASSIGN                                                   !4, $20
   27    22        INIT_FCALL                                               'explode'
         23        SEND_VAL                                                 '+'
         24        SEND_VAR                                                 !4
         25        DO_ICALL                                         $22     
         26        ASSIGN                                                   !5, $22
   30    27        ASSIGN                                                   !6, <array>
   31    28        INIT_FCALL                                               'array_diff'
         29        SEND_VAR                                                 !6
         30        SEND_VAR                                                 !5
         31        DO_ICALL                                         $25     
         32        BOOL_NOT                                         ~26     $25
         33      > JMPZ                                                     ~26, ->42
   33    34    >   INIT_METHOD_CALL                                         !3, 'getAttribute'
         35        SEND_VAL_EX                                              'src'
         36        DO_FCALL                                      0  $27     
         37        ASSIGN                                                   !7, $27
   34    38        ROPE_INIT                                     3  ~30     'URL%3A+'
         39        ROPE_ADD                                      1  ~30     ~30, !7
         40        ROPE_END                                      2  ~29     ~30, '%0A'
         41        ECHO                                                     ~29
   24    42    > > JMP                                                      ->17
         43    >   FE_FREE                                                  $19
   36    44      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.71 ms | 1400 KiB | 17 Q