Extract Query String from Form Submitted URL

$url = "http://www.youtube.com/watch?v=P22G8YHveEg&feature=feedrec_grec_index"
// get the query string of the url
$query_string = parse_url($url, PHP_URL_QUERY);
// parse out the query string into pieces
parse_str($query_string, $pieces);
// echo out the "v=" variable from the query string for storage in the DB and later use in a YouTube video plugin for WordPress
echo $pieces['v'];
// echos "P22G8YHveEg"


You must be logged in to post a comment.