4303 snippets from 2877 members, and growing!
|
login
|
join
about
bytebin
members
tags
snippets
join
Snippets
Submit a Snippet
Search Snippets
New Snippets
Top Snippets
Top Tags
Battery
(676)
Dell
(361)
Laptop
(289)
HP
(256)
adapter
(187)
stog
(177)
PHP
(164)
asus
(152)
stablo
(139)
JavaScript
(138)
Inspiron
(134)
strukture
(127)
polje
(120)
Akku
(102)
Batterie
(99)
New Snippets
Different Angles ...
Google beat Apple...
Magento Payment E...
Magento IP Restri...
Magento Extension...
Coleção...
A List Of Fiber O...
Dell machine boos...
android tv box TV...
VAG COM 11.11.3 a...
Venture Capital Jobs
New Members
magento
comsunshine
wellskaka
aussiegadget
batteriesmall
taylargreenson
chaonidaye
publishhome
seasoom
luca
Top Members
all-battery
dannyboy
tinydeal8388
jjanedan
sundaramkumar
batteryshops518
shenma
minideal
batteryerer
whiteyoung
Home
/
Snippets
/
YouTube ID extractor
/
Comments
YouTube ID extractor
Snippet Menu
Revisions
Comments
Related Snippets
Add to Favorites
Email Snippet
Download Snippet
Print Snippet
Blog Snippet
snippet
|
revisions
|
comments
|
related
|
Add to Favorites
|
email
download
|
print
|
blog it
New Comment
Nice
Thu. Aug. 23rd, 2007 8:42 AM
navster
Cool script, but how can one remove the extra variables YT sometimes puts at the end? I.e &mode=related&search=
Reply
Youtube Video ID only
Mon. Dec. 24th, 2007 7:16 PM
mmoraes
Try this. I hope it helps!
function
youtubeid
(
$url
)
{
if
(
preg_match
(
'%youtube
\\
.com/(.+)%'
, $url, $match
)
)
{
$match = $match
[
1
]
;
$replace = array
(
"watch?v="
,
"v/"
,
"vi/"
)
;
$match = str_replace
(
$replace,
""
, $match
)
;
//Below we remove everything after "&" (example: "&feature=related")
$match=array_shift
(
explode
(
'&'
, basename
(
$match
)
)
)
;
}
return
$match;
}
Reply
New Comment
function youtubeid($url) {
if (preg_match('%youtube\\.com/(.+)%', $url, $match)) {
$match = $match[1];
$replace = array("watch?v=", "v/", "vi/");
$match = str_replace($replace, "", $match);
//Below we remove everything after "&" (example: "&feature=related")
$match=array_shift(explode('&', basename($match)));
}
return $match;
}