$string = "youtube.com/watch?v=R0BA-KviNO4&feature=related"; preg_match('/v\=(.+)&/',$string,$matches); echo $matches[1];