3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<p>hello<a href="https://www.youtu.be/watch?v=7HknMcG2qYo">world</a></p><p>hello<a href="https://youtube.com/watch?v=37373o">world</a></p>'; $pattern = '/https?:\/\/(www\.)?youtu(\.be|\com)\/[a-zA-Z0-9\?=]*/i'; preg_match_all($pattern, $html, $matches); // print_r($matches); $first_found_youtube = $matches[0][0]; echo $first_found_youtube;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lFjmK
function name:  (null)
number of ops:  12
compiled vars:  !0 = $html, !1 = $pattern, !2 = $matches, !3 = $first_found_youtube
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, '%3Cp%3Ehello%3Ca+href%3D%22https%3A%2F%2Fwww.youtu.be%2Fwatch%3Fv%3D7HknMcG2qYo%22%3Eworld%3C%2Fa%3E%3C%2Fp%3E%3Cp%3Ehello%3Ca+href%3D%22https%3A%2F%2Fyoutube.com%2Fwatch%3Fv%3D37373o%22%3Eworld%3C%2Fa%3E%3C%2Fp%3E'
    6     1        ASSIGN                                                   !1, '%2Fhttps%3F%3A%5C%2F%5C%2F%28www%5C.%29%3Fyoutu%28%5C.be%7C%5Ccom%29%5C%2F%5Ba-zA-Z0-9%5C%3F%3D%5D%2A%2Fi'
    7     2        INIT_FCALL                                               'preg_match_all'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
   10     7        FETCH_DIM_R                                      ~7      !2, 0
          8        FETCH_DIM_R                                      ~8      ~7, 0
          9        ASSIGN                                                   !3, ~8
   11    10        ECHO                                                     !3
         11      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.75 ms | 1070 KiB | 14 Q