Taking only the "src" attribute

0

In my system, it should take only the "src" attribute from within a variable and put it in a new one, following the example:

//<iframe class="embed-responsive-item" src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Funiladmag%2Fvideos%2F4623781360978220%2F&show_text=0&width=476"width="476" height="476" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allowFullScreen="true"></iframe>
$iFrame = $_POST['vid_iframe'];

How would you do to just get what's inside the "src"? I tried to use an explode but it did not work.

    
asked by anonymous 28.11.2018 / 20:42

1 answer

1

If it is in php and its string is the iframe does so

$variavel='<iframe class="embed-responsive-item" src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Funiladmag%2Fvideos%2F4623781360978220%2F&show_text=0&width=476"width="476" height="476" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allowFullScreen="true"></iframe>';

$var=explode('src="',$variavel);
$var=explode('"',$var['1']);
echo $var['0'];
    
28.11.2018 / 21:52