Jim
Jim

Reputation: 1440

Getting keeks videos id from the link using php

I need to get just the Video Id from any keeks video link

Examples of Links from keeks.com

https://www.keek.com/syahrin/keeks/QC06cab
https://www.keek.com/!QC06cab
https://www.keek.com/syahrin#QC06cab
https://www.keek.com/embed/QC06cab

I need the output just QC06cab

Upvotes: 1

Views: 80

Answers (1)

Casimir et Hippolyte
Casimir et Hippolyte

Reputation: 89547

You can use a character class that exclude delimiters and anchor the pattern to the end of the string:

if (preg_match('~[^/!#]++$~', $url, $match))
    print_r($match);

Upvotes: 1

Related Questions