curl & parse_url

$feature_name = 'site_videos';
if($feature_name != ''){
	$items = json_decode($db->get_option($feature_name), true);
	foreach($items as $item){
		$vid = get_youtube_id($item['url'] . '&test=rex');
		$thumb = get_youtube_thumb($vid);
		echo '<li><a class="fancybox-media" href="' . $item['url'] . '">' . 
			'<img src="' . $thumb['url'] . '" border="0" width="' . $thumb['width'] . '" ' . 
			'height="' . $thumb['height'] . '" /></a></li>';
	}
}


function get_youtube_thumb($id){
	$api = 'http://gdata.youtube.com/feeds/api/videos/[vid]?v=2&prettyprint=true&alt=json';
	$api = str_replace('[vid]', $id, $api);

	$request = array(
		CURLOPT_RETURNTRANSFER => true //Important!
	);
	$ch = curl_init($api);
	curl_setopt_array($ch, $request);
	$result = curl_exec($ch);
	$data = json_decode($result, true);
	//print_r($data['entry']['media$group']['media$thumbnail'][0]);
	return $data['entry']['media$group']['media$thumbnail'][0];
}

function get_youtube_id($url){
	$query = parse_url($url, PHP_URL_QUERY);
	$params = explode('&', $query);
	$result = array();
	foreach($params as $key => $value){
		$arr = explode('=', $value);
		$result[$arr[0]] = $arr[1];
	}
	return $result['v'];
}