3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bigKml = "<Document><name>test2.kmz</name><br><img src='files/bagel.png'><br><br></Document>"; $titleTagPattern = '/<Document><name>.*?<\/name>/'; preg_match($titleTagPattern, $bigKml, $titleTags); $titleTag = $titleTags[0]; $len = strlen($titleTag); $docTagLen = 16; $nameEndTagLen = 7; $kmzTitle = substr($titleTag, $docTagLen, $len - $docTagLen - $nameEndTagLen); print_r($kmzTitle . "\n"); $imgPattern = "/<img src=.*?>/"; preg_match($imgPattern, $bigKml, $imageTags); print_r($imageTags); foreach($imageTags as $imageTag) { $urlPattern = "/'([^']*)'/"; preg_match($urlPattern, $imageTag, $oldUrls); $oldUrl = $oldUrls[1]; //the second element contains the match without the quotes print_r($oldUrl . "\n"); $newUrl = "/var/www/resources/" . $kmzTitle . $oldUrl; print_r($newUrl . "\n"); } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 35, Position 2 = 56
Branch analysis from position: 35
2 jumps found. (Code = 78) Position 1 = 36, Position 2 = 56
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
filename:       /in/SIYtt
function name:  (null)
number of ops:  58
compiled vars:  !0 = $bigKml, !1 = $titleTagPattern, !2 = $titleTags, !3 = $titleTag, !4 = $len, !5 = $docTagLen, !6 = $nameEndTagLen, !7 = $kmzTitle, !8 = $imgPattern, !9 = $imageTags, !10 = $imageTag, !11 = $urlPattern, !12 = $oldUrls, !13 = $oldUrl, !14 = $newUrl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3CDocument%3E%3Cname%3Etest2.kmz%3C%2Fname%3E%3Cbr%3E%3Cimg+src%3D%27files%2Fbagel.png%27%3E%3Cbr%3E%3Cbr%3E%3C%2FDocument%3E'
    4     1        ASSIGN                                                   !1, '%2F%3CDocument%3E%3Cname%3E.%2A%3F%3C%5C%2Fname%3E%2F'
    5     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
    6     7        FETCH_DIM_R                                      ~18     !2, 0
          8        ASSIGN                                                   !3, ~18
    7     9        STRLEN                                           ~20     !3
         10        ASSIGN                                                   !4, ~20
    8    11        ASSIGN                                                   !5, 16
    9    12        ASSIGN                                                   !6, 7
   10    13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !3
         15        SEND_VAR                                                 !5
         16        SUB                                              ~24     !4, !5
         17        SUB                                              ~25     ~24, !6
         18        SEND_VAL                                                 ~25
         19        DO_ICALL                                         $26     
         20        ASSIGN                                                   !7, $26
   11    21        INIT_FCALL                                               'print_r'
         22        CONCAT                                           ~28     !7, '%0A'
         23        SEND_VAL                                                 ~28
         24        DO_ICALL                                                 
   13    25        ASSIGN                                                   !8, '%2F%3Cimg+src%3D.%2A%3F%3E%2F'
   14    26        INIT_FCALL                                               'preg_match'
         27        SEND_VAR                                                 !8
         28        SEND_VAR                                                 !0
         29        SEND_REF                                                 !9
         30        DO_ICALL                                                 
   15    31        INIT_FCALL                                               'print_r'
         32        SEND_VAR                                                 !9
         33        DO_ICALL                                                 
   17    34      > FE_RESET_R                                       $33     !9, ->56
         35    > > FE_FETCH_R                                               $33, !10, ->56
   18    36    >   ASSIGN                                                   !11, '%2F%27%28%5B%5E%27%5D%2A%29%27%2F'
   19    37        INIT_FCALL                                               'preg_match'
         38        SEND_VAR                                                 !11
         39        SEND_VAR                                                 !10
         40        SEND_REF                                                 !12
         41        DO_ICALL                                                 
   20    42        FETCH_DIM_R                                      ~36     !12, 1
         43        ASSIGN                                                   !13, ~36
   21    44        INIT_FCALL                                               'print_r'
         45        CONCAT                                           ~38     !13, '%0A'
         46        SEND_VAL                                                 ~38
         47        DO_ICALL                                                 
   22    48        CONCAT                                           ~40     '%2Fvar%2Fwww%2Fresources%2F', !7
         49        CONCAT                                           ~41     ~40, !13
         50        ASSIGN                                                   !14, ~41
   23    51        INIT_FCALL                                               'print_r'
         52        CONCAT                                           ~43     !14, '%0A'
         53        SEND_VAL                                                 ~43
         54        DO_ICALL                                                 
   17    55      > JMP                                                      ->35
         56    >   FE_FREE                                                  $33
   25    57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.4 ms | 1400 KiB | 19 Q