I want to use preg_split to split this URL up and return the part in red so split it up by the forward slash
http://i4.ytimg.com/vi/[COLOR=“Red”]_ZSTQad4Svs[/COLOR]/hqdefault.jpg
Not great with regular expressions so any help would be great.
Cheers
Martin
Unless there are any other requirements/considerations, you could probably do without a RegEx here. 
<?php
$url = 'http://i4.ytimg.com/vi/_ZSTQad4Svs/hqdefault.jpg';
print_r(
explode('/', parse_url($url, PHP_URL_PATH))
);
/*
Array
(
[0] =>
[1] => vi
[2] => _ZSTQad4Svs
[3] => hqdefault.jpg
)
*/
Thanks for the speedy reply I actually pasted the wrong URL
I need to split the id from the url which is highlighted in red.
<?php
$url = 'http://www.youtube.com/watch?v=VCrP20x0q7Q';
parse_str(parse_url($url, PHP_URL_QUERY), $parts);
print_r($parts);
/*
Array
(
[v] => VCrP20x0q7Q
)
*/
<?php
$url = ‘http://www.youtube.com/watch?v=VCrP20x0q7Q’;
print_r(explode(‘=’,$url));
?>
/*
Array
(
[0] => http://www.youtube.com/watch?v
[1] => VCrP20x0q7Q
)
*/