3v4l.org

run code in 500+ PHP versions simultaneously
<?php function check_link($link) { if(preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $link, $r)) { $pattern = '#<a\s?href="(https?:\/\/(?:www.)?[\w.\#\/?=]+)">\1<\/a>#is'; return preg_replace($pattern,'<iframe width="560" height="315" src="https://www.youtube.com/embed/'.$r[0].'" frameborder="0"></iframe>',$link); } } echo check_link('<a href="https://www.youtube.com/watch?v=Z7Oc8QaM5VU">https://www.youtube.com/watch?v=Z7Oc8QaM5VU</a>');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kY1eb
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   INIT_FCALL                                                   'check_link'
          1        SEND_VAL                                                     '%3Ca+href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZ7Oc8QaM5VU%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZ7Oc8QaM5VU%3C%2Fa%3E'
          2        DO_FCALL                                          0  $0      
          3        ECHO                                                         $0
          4      > RETURN                                                       1

Function check_link:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kY1eb
function name:  check_link
number of ops:  15
compiled vars:  !0 = $link, !1 = $r, !2 = $pattern
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'preg_match'
          2        SEND_VAL                                                     '%23%28%3F%3C%3Dv%3D%29%5Ba-zA-Z0-9-%5D%2B%28%3F%3D%26%29%7C%28%3F%3C%3Dv%5C%2F%29%5B%5E%26%0A%5D%2B%28%3F%3D%5C%3F%29%7C%28%3F%3C%3Dv%3D%29%5B%5E%26%0A%5D%2B%7C%28%3F%3C%3Dyoutu.be%2F%29%5B%5E%26%0A%5D%2B%23'
          3        SEND_VAR                                                     !0
          4        SEND_REF                                                     !1
          5        DO_ICALL                                             $3      
          6      > JMPZ                                                         $3, ->14
    6     7    >   ASSIGN                                                       !2, '%23%3Ca%5Cs%3Fhref%3D%22%28https%3F%3A%5C%2F%5C%2F%28%3F%3Awww.%29%3F%5B%5Cw.%5C%23%5C%2F%3F%3D%5D%2B%29%22%3E%5C1%3C%5C%2Fa%3E%23is'
    7     8        FETCH_DIM_R                                          ~5      !1, 0
          9        CONCAT                                               ~6      '%3Ciframe+width%3D%22560%22+height%3D%22315%22+src%3D%22https%3A%2F%2Fwww.youtube.com%2Fembed%2F', ~5
         10        CONCAT                                               ~7      ~6, '%22+frameborder%3D%220%22%3E%3C%2Fiframe%3E'
         11        FRAMELESS_ICALL_3                preg_replace        ~8      !2, ~7
         12        OP_DATA                                                      !0
         13      > RETURN                                                       ~8
    9    14    > > RETURN                                                       null

End of function check_link

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
175.9 ms | 2126 KiB | 15 Q