3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '/(.*?)(\[\w{3}=\')(\w+\.\w+)(\'\])(.*?)(\[\w{3}=\')(\w+\.\w+).*/s'; $str = 'Hello, view this pdf [PDF=\'hello.pdf\'] and then view this PDF [PDF=\'goodmorning.pdf\'] Hello, view this pdf <object data="https://myurl.com/media/hello.pdf" class="pdf-shortcode- iframe" type="application/pdf"> <iframe class="pdf-shortcode-iframe" src="https://docs.google.com/viewer? url=https://myurl.com/media/hello.pdf&embedded=true"></iframe> </object> and then view this PDF <object data="https://myurl.com/media/goodmorning.pdf" class="pdf- shortcode-iframe" type="application/pdf"> <iframe class="pdf-shortcode-iframe" src="https://docs.google.com/viewer? url=https://myurl.com/media/hello.pdf&embedded=true"></iframe> </object>'; $subst = '$1 <object data=\\"https://myurl.com/media/$3\\" class=\\"pdf-shortcode-iframe" type=\\"application/pdf\\"> <iframe class=\\"pdf-shortcode-iframe\\" src=\\"https://docs.google.com/viewer?url=https://myurl.com/media/$3&embedded=true\\"></iframe> </object>$5 <object data=\\"https://myurl.com/media/$7\\" class=\\"pdf-shortcode-iframe\\" type=\\"application/pdf\\"> <iframe class=\\"pdf-shortcode-iframe\\" src=\\"https://docs.google.com/viewer? url=https://myurl.com/media/$3&embedded=true"></iframe> </object>'; $result = preg_replace($re, $subst, $str); echo "The result of the substitution is ".$result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6IYCP
function name:  (null)
number of ops:  12
compiled vars:  !0 = $re, !1 = $str, !2 = $subst, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2F%28.%2A%3F%29%28%5C%5B%5Cw%7B3%7D%3D%27%29%28%5Cw%2B%5C.%5Cw%2B%29%28%27%5C%5D%29%28.%2A%3F%29%28%5C%5B%5Cw%7B3%7D%3D%27%29%28%5Cw%2B%5C.%5Cw%2B%29.%2A%2Fs'
    4     1        ASSIGN                                                   !1, 'Hello%2C+view+this+pdf+%5BPDF%3D%27hello.pdf%27%5D+%0Aand+then+view+this+PDF+%5BPDF%3D%27goodmorning.pdf%27%5D%0A%0A%0AHello%2C+view+this+pdf++%3Cobject+data%3D%22https%3A%2F%2Fmyurl.com%2Fmedia%2Fhello.pdf%22+class%3D%22pdf-shortcode-%0A++iframe%22+type%3D%22application%2Fpdf%22%3E%0A++%3Ciframe+class%3D%22pdf-shortcode-iframe%22+src%3D%22https%3A%2F%2Fdocs.google.com%2Fviewer%3F%0A++url%3Dhttps%3A%2F%2Fmyurl.com%2Fmedia%2Fhello.pdf%26embedded%3Dtrue%22%3E%3C%2Fiframe%3E%0A+++%3C%2Fobject%3E%0A+++and+then+view+this+PDF%0A++%3Cobject+data%3D%22https%3A%2F%2Fmyurl.com%2Fmedia%2Fgoodmorning.pdf%22+class%3D%22pdf-%0A++++shortcode-iframe%22+type%3D%22application%2Fpdf%22%3E%0A+++%3Ciframe+class%3D%22pdf-shortcode-iframe%22+src%3D%22https%3A%2F%2Fdocs.google.com%2Fviewer%3F%0A+++url%3Dhttps%3A%2F%2Fmyurl.com%2Fmedia%2Fhello.pdf%26embedded%3Dtrue%22%3E%3C%2Fiframe%3E%0A++++%3C%2Fobject%3E'
   19     2        ASSIGN                                                   !2, '%241+%3Cobject+data%3D%5C%22https%3A%2F%2Fmyurl.com%2Fmedia%2F%243%5C%22++class%3D%5C%22pdf-shortcode-iframe%22+type%3D%5C%22application%2Fpdf%5C%22%3E++%3Ciframe+class%3D%5C%22pdf-shortcode-iframe%5C%22+src%3D%5C%22https%3A%2F%2Fdocs.google.com%2Fviewer%3Furl%3Dhttps%3A%2F%2Fmyurl.com%2Fmedia%2F%243%26embedded%3Dtrue%5C%22%3E%3C%2Fiframe%3E+++%3C%2Fobject%3E%245+%3Cobject+data%3D%5C%22https%3A%2F%2Fmyurl.com%2Fmedia%2F%247%5C%22+class%3D%5C%22pdf-shortcode-iframe%5C%22+type%3D%5C%22application%2Fpdf%5C%22%3E+++%3Ciframe+class%3D%5C%22pdf-shortcode-iframe%5C%22+src%3D%5C%22https%3A%2F%2Fdocs.google.com%2Fviewer%3F+++url%3Dhttps%3A%2F%2Fmyurl.com%2Fmedia%2F%243%26embedded%3Dtrue%22%3E%3C%2Fiframe%3E++++%3C%2Fobject%3E'
   21     3        INIT_FCALL                                               'preg_replace'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !3, $7
   23     9        CONCAT                                           ~9      'The+result+of+the+substitution+is+', !3
         10        ECHO                                                     ~9
         11      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.34 ms | 1396 KiB | 15 Q