Thread: Youtube Videos
View Single Post
Old 02-17-2008, 01:16 AM   #5 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Thank you ! You could port it over to PHP 4, although such functions as get_header are not available in PHP 4, though there are ways around that by using cURL.

Owen: Help yourself! Give TalkPHP a little mention though when you can please!

I modified the setAddress function earlier. Merely to ensure it can always extract the ID where available. Whereas the previous version, if there's any data trailing the YouTube ID, then it wouldn't work correctly.

php Code:
public function setAddress($szIdentifier)
{
    if(!preg_match('~^[a-z]+$~', $szIdentifier))
    {
        preg_match('~.+?v=(?P<identifier>[^&]+).*~i', $szIdentifier, $aMatches);
        $szIdentifier = $aMatches['identifier'];
    }
           
    $this->m_szIdentifier = $szIdentifier;
           
    return true;
}
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote