Since all you want to do is check for the presence of a string, use stripos. If it doesn't have youtube.com or vimeo.com in it, the url is malformed, right? stripos is case insensitive, too.
if(stripos($url,'youtu')===false){
//must be vimeo
} else {
//is youtube
}