Last active
April 22, 2019 16:52
-
-
Save DenoGeek/e72345c25825158d057c0577840247c8 to your computer and use it in GitHub Desktop.
Src pregmatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$iframe_string = '<iframe width="100%" height="315" src="https://www.youtube.com/embed/-XC6r9SIQfo" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'; | |
preg_match('/src="([^"]+)"/', $iframe_string, $match); | |
/*Output all the matches by the expression*/ | |
print_r($match); | |
/*Get the index of the array*/ | |
$url = $match[1]; | |
echo $url; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment