How do I get the Video Id from the URL? (DailyMotion)

前端 未结 5 1869
北恋
北恋 2020-12-30 14:10

Example:

http://www.dailymotion.com/video/x4xvnz_the-funny-crash-compilation_fun

How do I get x4xvnz?

5条回答
  •  醉话见心
    2020-12-30 14:40

    You can use basename [docs] to get the last part of the URL and then strtok [docs] to get the ID (all characters up to the first _):

    $id = strtok(basename($url), '_');
    

提交回复
热议问题