YouTube parse video id from links
<p>Using a Youtube Channel how do I parse the $link variable and get the video ID? I can get the links but the parse_str part doesn't seem to be working properly</p>

<p><strong>youtube id parsing: trying to get to work with current code below</strong></p>

<pre><code>if ( ! empty($xml-&gt;channel-&gt;item[0]-&gt;link) )
{
  parse_str(parse_url($xml-&gt;channel-&gt;item[0]-&gt;link, PHP_URL_QUERY), $url_query);

  if ( ! empty($url_query['v']) )
    $id = $url_query['v'];
}

echo $id;
</code></pre>

<p><strong>current code:</strong></p>

<pre><code>    &lt;?php
    $id = NULL;
    $username = 'utahblaze';
    $url = 'http://gdata.youtube.com/feeds/api/users/%s/uploads?orderby=updated&amp;max-results=8';
    $xml = simplexml_load_file(sprintf($url, $username));

    foreach ($xml-&gt;entry as $entry) :

        $kids = $entry-&gt;children('http://search.yahoo.com/mrss/');
        $attributes = $kids-&gt;group-&gt;content[0]-&gt;attributes();
        $flv = $attributes['url'];
        $attributes = $kids-&gt;group-&gt;player-&gt;attributes();
        $link = $attributes['url']; 


    echo $id;
    echo $link;

    ?&gt;

&lt;a id="ytopen" href="&lt;?=$link?&gt;"&gt;
&lt;img src="http://i4.ytimg.com/vi/&lt;?=$id?&gt;/default.jpg" /&gt;&lt;/a&gt;

    &lt;?php endforeach; ?&gt;
</code></pre>
