Hello,

I currently have a function that determines if there is a youtube URL located in a text entry entered by a user. I have set this up to locate the url and parse it and store it as a variable. I then check if the variable is set and if it is I embed the video with youtube's supplied iframe code. The issue I am having is when there are multiple youtube urls added the function only embeds the first added youtube url and ignores the others. Here is the function that I am using to search for the youtube url:

PHP Code:

function get_youtube_id($ytURL) {
                
$ytvIDlen 11;
                
$ytURL str_replace('http://youtu.be/'''$ytURL);
                if(
strlen($ytURL) == $ytvIDlen) {return $ytURL;}
                
$idStarts strpos($ytURL"?v=");
                if(
$idStarts === FALSE) { $idStarts strpos($ytURL"&v=");}
                if(
$idStarts === FALSE) { return FALSE;}
                
$idStarts +=3;
                
$ytvID substr($ytURL$idStarts$ytvIDlen);
                return 
$ytvID;
            } 
then i run the user's message through the function to store the video id as a variable:

PHP Code:

$videoID 
get_youtube_id($messages['message']);
                        if (
$videoID) {
                            
$videoPOST ='<iframe id="ytplayer" type="text/html" width="400" height="225"src="https://www.youtube.com/embed/' $videoID '?theme=light"frameborder="0" allowfullscreen></iframe>';
                        }else{
                            
$videoPOST FALSE;
                        } 
if there is no youtube url then $videoPOST is set to FALSE. I just need help to adjust this to check to see if there are multiple youtube urls. Any help or suggestions you can give would be very helpful.