hi with a simple form, i get the "a" variable to the url parse file as below.
my goal is to obtain youtube video thumbnails when i enter url. but this doesnt work with some youtube urls for instance such as:
http://www.youtube.com/watch?v=OC2TTslf_YM
the code below doesnt work to obtain youtube thumbnail when i enter this url to the form which send "a" to this file... what modifications should i make in the code below so it works with this url too (and of course still working with the previous urls)
PHP Code:
$regexp = '/v=(-?[a-z0-9]+)/i';
$url=$_POST['a'];
if (preg_match($regexp, $url, $matches)) {
$a = $matches[1];
}
else {
echo 'No match found';
}
$url2='http://img.youtube.com/vi/$id/default.jpg';
$result=str_replace ( '$id' , $a , $url2 );
echo '<img src="'.$result.'" />';