3v4l.org

run code in 300+ PHP versions simultaneously
<?php $content = <<<EOT <p>List of sample images.</p> <img src="https://placehold.it/250x100/99cc00/000.jpg?text=JPG" alt="JPG" /><br> <img src="https://placehold.it/250x100.gif?text=GIF" alt="GIF" /><br> <img src="https://placehold.it/250x100/ff6600/000.png?text=PNG" alt="PNG" /><br> <img class="no-ext" src="https://placehold.it/350x150?text=No Extension" alt="No Ext" /><br> <img src="https://placehold.it/250x100.png" custom-attr="custom1" another-attr="custom2" /><br> <img class="svg" src="https://upload.wikimedia.org/wikipedia/commons/0/02/SVG_logo.svg" alt="SVG" /><br> <img class="webp" src="https://gstatic.com/webp/gallery/1.webp" width="100" alt="webP" /><br> EOT; # Find all content with <img> tags preg_match_all( '/(?:<img|(?<!^)\G)\h*([-\w]+)="([^"]+)"(?=.*?\/>)/', $content, $images ); foreach ( $images[1] as $attributes[1] => $value ) { echo( '< img ' . $value . '="' . 'value' . '" ><br>' ); } //echo "<pre>"; print_r($images); $temp = array(); foreach($images[0] as $key=>$img){ $pos = strpos($img,'<img'); if($pos === false){ $temp[$key_2][] = $img; }else{ $temp[$key][] = $img; $key_2 = $key; } } foreach($temp as $k=>$v){ $str[] = implode(' ', $v) . ' />'; } $finalStr = implode('<br />', $str); echo $finalStr;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 39
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 39
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 39
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 51
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 51
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
Branch analysis from position: 39
Branch analysis from position: 17
filename:       /in/coZbN
function name:  (null)
number of ops:  59
compiled vars:  !0 = $content, !1 = $images, !2 = $value, !3 = $attributes, !4 = $temp, !5 = $img, !6 = $key, !7 = $pos, !8 = $key_2, !9 = $v, !10 = $k, !11 = $str, !12 = $finalStr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cp%3EList+of+sample+images.%3C%2Fp%3E%0A%3Cimg+src%3D%22https%3A%2F%2Fplacehold.it%2F250x100%2F99cc00%2F000.jpg%3Ftext%3DJPG%22+alt%3D%22JPG%22+%2F%3E%3Cbr%3E%0A%3Cimg+src%3D%22https%3A%2F%2Fplacehold.it%2F250x100.gif%3Ftext%3DGIF%22+alt%3D%22GIF%22+%2F%3E%3Cbr%3E%0A%3Cimg+src%3D%22https%3A%2F%2Fplacehold.it%2F250x100%2Fff6600%2F000.png%3Ftext%3DPNG%22+alt%3D%22PNG%22+%2F%3E%3Cbr%3E%0A%3Cimg+class%3D%22no-ext%22+src%3D%22https%3A%2F%2Fplacehold.it%2F350x150%3Ftext%3DNo+Extension%22+alt%3D%22No+Ext%22+%2F%3E%3Cbr%3E%0A%3Cimg+src%3D%22https%3A%2F%2Fplacehold.it%2F250x100.png%22+custom-attr%3D%22custom1%22+another-attr%3D%22custom2%22+%2F%3E%3Cbr%3E%0A%3Cimg+class%3D%22svg%22+src%3D%22https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2F0%2F02%2FSVG_logo.svg%22+alt%3D%22SVG%22+%2F%3E%3Cbr%3E%0A%3Cimg+class%3D%22webp%22+src%3D%22https%3A%2F%2Fgstatic.com%2Fwebp%2Fgallery%2F1.webp%22+width%3D%22100%22+alt%3D%22webP%22+%2F%3E%3Cbr%3E'
   13     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%28%3F%3A%3Cimg%7C%28%3F%3C%21%5E%29%5CG%29%5Ch%2A%28%5B-%5Cw%5D%2B%29%3D%22%28%5B%5E%22%5D%2B%29%22%28%3F%3D.%2A%3F%5C%2F%3E%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
   14     6        FETCH_DIM_R                                      ~15     !1, 1
          7      > FE_RESET_R                                       $16     ~15, ->17
          8    > > FE_FETCH_R                                       ~17     $16, !2, ->17
          9    >   ASSIGN_DIM                                               !3, 1
         10        OP_DATA                                                  ~17
   15    11        CONCAT                                           ~19     '%3C+img+', !2
         12        CONCAT                                           ~20     ~19, '%3D%22'
         13        CONCAT                                           ~21     ~20, 'value'
         14        CONCAT                                           ~22     ~21, '%22+%3E%3Cbr%3E'
         15        ECHO                                                     ~22
   14    16      > JMP                                                      ->8
         17    >   FE_FREE                                                  $16
   18    18        ASSIGN                                                   !4, <array>
   19    19        FETCH_DIM_R                                      ~24     !1, 0
         20      > FE_RESET_R                                       $25     ~24, ->39
         21    > > FE_FETCH_R                                       ~26     $25, !5, ->39
         22    >   ASSIGN                                                   !6, ~26
   20    23        INIT_FCALL                                               'strpos'
         24        SEND_VAR                                                 !5
         25        SEND_VAL                                                 '%3Cimg'
         26        DO_ICALL                                         $28     
         27        ASSIGN                                                   !7, $28
   21    28        TYPE_CHECK                                    4          !7
         29      > JMPZ                                                     ~30, ->34
   22    30    >   FETCH_DIM_W                                      $31     !4, !8
         31        ASSIGN_DIM                                               $31
         32        OP_DATA                                                  !5
   21    33      > JMP                                                      ->38
   24    34    >   FETCH_DIM_W                                      $33     !4, !6
         35        ASSIGN_DIM                                               $33
         36        OP_DATA                                                  !5
   25    37        ASSIGN                                                   !8, !6
   19    38    > > JMP                                                      ->21
         39    >   FE_FREE                                                  $25
   28    40      > FE_RESET_R                                       $36     !4, ->51
         41    > > FE_FETCH_R                                       ~37     $36, !9, ->51
         42    >   ASSIGN                                                   !10, ~37
   29    43        INIT_FCALL                                               'implode'
         44        SEND_VAL                                                 '+'
         45        SEND_VAR                                                 !9
         46        DO_ICALL                                         $40     
         47        CONCAT                                           ~41     $40, '+%2F%3E'
         48        ASSIGN_DIM                                               !11
         49        OP_DATA                                                  ~41
   28    50      > JMP                                                      ->41
         51    >   FE_FREE                                                  $36
   32    52        INIT_FCALL                                               'implode'
         53        SEND_VAL                                                 '%3Cbr+%2F%3E'
         54        SEND_VAR                                                 !11
         55        DO_ICALL                                         $42     
         56        ASSIGN                                                   !12, $42
   34    57        ECHO                                                     !12
         58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.93 ms | 1005 KiB | 16 Q