How to separate url into a embed code of youtube?

how to separate url from a embed code of youtube?

there is a solution for Get url into a  embed code of youtube

function getyoutubeVideolink($code){
    $a = array();
    $b = array();
    $c = array();

    $a = explode('src',$code);
    $b = explode('frameborder',$a[1]);
    $b = explode('frameborder',$b[0]);
    $c = explode('"',$b[0]);

    return $c[1];
    }

$embed_code = '<iframe width="420" height="315" src="http://www.youtube.com/embed/GwQMnpUsj8I" frameborder="0" allowfullscreen></iframe>';

$url = getyoutubeVideolink($embed_code);
echo $url;

Now you can use this url in a iframe and where do you want

Comments