3v4l.org

run code in 300+ PHP versions simultaneously
<?php $imageTag = '<img src = http://nycxplorer.com/wp-content/uploads/2012/02/bagel1-1.jpg >'; //grab the src portion of the image tag $srcPattern = "/src.*?=.*?>/s"; preg_match($srcPattern, $imageTag, $srcParts); $srcPart = $srcParts[0]; print_r($srcPart); //remove all whitespace from within and around the src portion $srcPart = trim(preg_replace('/[\s]+/','', $srcPart)); print_r($srcPart); //grab the src URL $oldUrl = substr($srcPart, 4); //if there are quotes at the beginning of the url, cut them off if(strpos($oldUrl, '"') == 0 || strpos($oldUrl, "'") == 0) { $oldUrl = substr($oldUrl, 1, strlen($oldUrl)-2); } print_r($oldUrl); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 35, Position 2 = 41
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 50
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
Branch analysis from position: 41
filename:       /in/L52F7
function name:  (null)
number of ops:  54
compiled vars:  !0 = $imageTag, !1 = $srcPattern, !2 = $srcParts, !3 = $srcPart, !4 = $oldUrl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cimg+src+++++%3D+++++http%3A%2F%2Fnycxplorer.com%2Fwp-content%2Fuploads%2F2012%2F02%2Fbagel1-1.jpg++++%3E'
    5     1        ASSIGN                                                   !1, '%2Fsrc.%2A%3F%3D.%2A%3F%3E%2Fs'
    6     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
    7     7        FETCH_DIM_R                                      ~8      !2, 0
          8        ASSIGN                                                   !3, ~8
    8     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                                 
   10    12        INIT_FCALL                                               'trim'
         13        INIT_FCALL                                               'preg_replace'
         14        SEND_VAL                                                 '%2F%5B%5Cs%5D%2B%2F'
         15        SEND_VAL                                                 ''
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $11     
         18        SEND_VAR                                                 $11
         19        DO_ICALL                                         $12     
         20        ASSIGN                                                   !3, $12
   11    21        INIT_FCALL                                               'print_r'
         22        SEND_VAR                                                 !3
         23        DO_ICALL                                                 
   14    24        INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !3
         26        SEND_VAL                                                 4
         27        DO_ICALL                                         $15     
         28        ASSIGN                                                   !4, $15
   17    29        INIT_FCALL                                               'strpos'
         30        SEND_VAR                                                 !4
         31        SEND_VAL                                                 '%22'
         32        DO_ICALL                                         $17     
         33        IS_EQUAL                                         ~18     $17, 0
         34      > JMPNZ_EX                                         ~18     ~18, ->41
         35    >   INIT_FCALL                                               'strpos'
         36        SEND_VAR                                                 !4
         37        SEND_VAL                                                 '%27'
         38        DO_ICALL                                         $19     
         39        IS_EQUAL                                         ~20     $19, 0
         40        BOOL                                             ~18     ~20
         41    > > JMPZ                                                     ~18, ->50
   18    42    >   INIT_FCALL                                               'substr'
         43        SEND_VAR                                                 !4
         44        SEND_VAL                                                 1
         45        STRLEN                                           ~21     !4
         46        SUB                                              ~22     ~21, 2
         47        SEND_VAL                                                 ~22
         48        DO_ICALL                                         $23     
         49        ASSIGN                                                   !4, $23
   20    50    >   INIT_FCALL                                               'print_r'
         51        SEND_VAR                                                 !4
         52        DO_ICALL                                                 
   21    53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.69 ms | 1405 KiB | 25 Q