Created
September 16, 2018 08:03
-
-
Save iamrobert/28bcebc88d8d0e15f6f0063dc14c1f50 to your computer and use it in GitHub Desktop.
Strip Youtube URL to get Video 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 characters
| <?php if(strip_tags($row[0]) == 'Video'): ?> | |
| <?php if($row[9] != NULL) :?> | |
| <?php | |
| $datavideo = strip_tags($row[9][0]); | |
| $datavideo = str_replace("href=","", $datavideo); | |
| $datavideo = preg_replace('/\s+/', '', $datavideo); | |
| $datavideo = preg_replace('/\"/', '', $datavideo); | |
| //$datavideo = preg_replace('\"', '', $datavideo); | |
| if (preg_match('/^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/', $datavideo, $match)) { | |
| $datavideo = $match[1]; | |
| // echo '<div class="itemx">';class="" | |
| echo '<div class="itemx item-video video-slide"><div class="grid-container video"> | |
| <div class="cell"> | |
| <div class="shadowx gv"><div class="maxh"><div data-type="youtube" data-video-id="'.$datavideo.'" class="js-player"></div></div></div> </div> | |
| </div> | |
| </div>'; | |
| //echo '<div data-type="youtube" data-video-id="dZTZyX5D7Qg" class="js-player"></div>'; | |
| // echo '</div>'; | |
| } | |
| ?> | |
| <?php endif;?> | |
| <?php endif;?> | |
| <?php endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment