<?php
$url = "http://www.youtube.com/watch?v=C4kxS1ksqtw&feature=relate";
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
echo $my_array_of_vars['v'];
// Output: C4kxS1ksqtw
?>
preg_match("/^(?:http(?:s)?://)?(?:www.)?(?:m.)?(?:youtu.be/|youtube.com/(?:(?:watch)??(?:.*&)?v(?:i)?=|(?:embed|v|vi|user|shorts)/))([^?&"'>]+)/", $url, $matches);