Created
May 25, 2021 13:03
-
-
Save relwen/1ae6f1b128c9dacbbe65be7ea859f51a to your computer and use it in GitHub Desktop.
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
#$data->lien_video is the link vidéo get on DB; example: https://youtu.be/example | |
#youtube vidéo links are: https://youtu.be/example or https://www.youtube.com/watch?v=9CHSMylQYdw | |
$data = "$data->lien_video"; | |
$search = "youtu.be"; | |
if(preg_match("/{$search}/i", $data)) { | |
$str_data = substr($data, strpos($data, "e/") + 2); | |
} | |
else { | |
$str_data = substr($data, strpos($data, "=") + 1); | |
} | |
// echo $str_data; | |
echo "<iframe src='https://www.youtube.com/embed/$str_data'> | |
</iframe>" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great