This function is only working sometimes
<pre><code>function getYoutubeVideoId($url) {
    $urlParts = parse_url($url);

    if($urlParts === false)
        return false;

    if(isset($urlParts['host']) &amp;&amp; strtolower($urlParts['host']) === 'youtu.be')
        return ltrim($urlParts['path'], '/');

    if(isset($urlParts['query'])) {
        parse_str($urlParts['query'], $queryParts);

        if(isset($queryParts['v']))
            return $queryParts['v'];
    }

    return false;
}
</code></pre>

<p>This function works great.. unless you use <code>youtu.be/*</code> without <code>http://</code></p>

<p>Why does it not work if it is just <code>youtu.be</code> or <code>www.youtu.be</code> ?</p>
