Grab the video ID from YouTube URL?

前端 未结 5 1956
臣服心动
臣服心动 2021-01-23 11:38

Say I have a list of IDs like so:

http://www.youtube.com/watch?v=KMU0tzLwhbE
http://youtu.be/KMU0tzLwhbE
http://www.youtube.com/watch?v=KMU0tzLwhbE&featured=         


        
5条回答
  •  误落风尘
    2021-01-23 12:38

    Do not use regexes for this. URIs have a particular grammar and PHP gives you the tools required to parse each URL properly. See parse_url() and parse_str().

提交回复
热议问题