Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Temp store the exploded URL
- $tmp = explode('/', $url);
- // Get the end of the array and go back two
- $videos = strtolower($tmp[count($tmp) - 2]);
- // Check if the URL is /username/videos/
- if ($videos == 'videos') {
- // Then the ID is located back one
- $id = $tmp[count($tmp) - 1];
- return $id;
- }else {
- // They used the ?v=id URL
- parse_str(parse_url($url)['query'], $query);
- // Check if it's empty or not
- if (!empty($query['v'])) {
- // The ID is within the ?v=
- $id = $query['v'];
- } else {
- // Oh crap shoot, it's neither!
- var_dump($tmp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement