-
-
Save vaporic/7fdd2ff5b99f56f5bbe4b72f7b9d4cba to your computer and use it in GitHub Desktop.
Revisions
-
lenivene revised this gist
Sep 8, 2016 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,9 @@ # Example code ```php $link = "https://www.youtube.com/watch?v=sOnqjkJTMaA"; $youtube_ID = get_youtube_ID( $link ); echo $youtube_ID; ``` ```html -
lenivene revised this gist
Sep 8, 2016 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,13 @@ # Example code ```php <?php $link = "https://www.youtube.com/watch?v=sOnqjkJTMaA"; $youtube_ID = get_youtube_ID( $link ); echo $youtube_ID; ?> ``` ```html <iframe width="560" height="315" src="https://www.youtube.com/embed/<?php echo $youtube_ID; ?>" frameborder="0" allowfullscreen></iframe> ``` -
lenivene revised this gist
Sep 6, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,6 @@ $youtube_ID = get_youtube_ID( $link ); echo $youtube_ID; <iframe width="560" height="315" src="https://www.youtube.com/embed/<?php echo $youtube_ID; ?>" frameborder="0" allowfullscreen></iframe> ``` -
lenivene revised this gist
Sep 6, 2016 . 2 changed files with 19 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # Example code ```php $link = "https://www.youtube.com/watch?v=sOnqjkJTMaA"; $youtube_ID = get_youtube_ID( $link ); echo $youtube_ID; ``` This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -5,5 +5,14 @@ * @var string $link [ https, m., gaming., www., youtube.com gaming.youtube.com, youtu.be ] * @return array $youtube URL && ID */ function get_youtube_ID( $link ){ if( !isset( $link ) || empty( $link ) ) return; preg_match( '/(?:https?:\/\/|www\.|gaming\.|m\.|^)youtu(?:be\.com\/watch\?(?:.*?&(?:amp;)?)?v=|\.be\/)([\w\-]+)(?:&(?:amp;)?[\w\?=]*)?/', $link, $ID ); $YouTube_ID = isset( $ID[1] ) ? $ID[1] : false; return $YouTube_ID; } -
lenivene created this gist
Jul 22, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ <?php /** * Get YouTube url ID * * @var string $link [ https, m., gaming., www., youtube.com gaming.youtube.com, youtu.be ] * @return array $youtube URL && ID */ $link = ''; // url here preg_match( '/(?:https?:\/\/|www\.|gaming\.|m\.|^)youtu(?:be\.com\/watch\?(?:.*?&(?:amp;)?)?v=|\.be\/)([\w\-]+)(?:&(?:amp;)?[\w\?=]*)?/', $link, $youtube );