if(preg_match("/http:\/\/www.youtube\.com\/watch\?v=(.*)/i", $url, $matches)) { $url = 'http://www.youtube.com/v/'.$matches[1];}