WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Embed Videos
Categories : PHP, HTML and PHP, Beginner Guides Click here to Update Your Picture
Vinod Mohan
Date : Dec 31st 2008
Grade : 2 of 5 (graded 3 times)
Viewed : 6614
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Vinod Mohan
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

This example shows how to embed a YouTube or MetaCafe video in your webpage by providing the url of the video page. The example uses regular expression to get the id of the youtube video and id and name of the Metacafe video, which is used to generate the code for embedding the video. The generated code is compatible with the code provided by Youtube and metacafe.

To embed a video, pass the url of video page to the function embedVideo.

<?php
function embedVideo($url){
    if(
preg_match("#http://(.*)\.youtube\.com/watch\?v=(.*)(&(.*))?#", $url, $matches)){
       
?>
        <object width="425" height="344">
        <param name="movie" value="http://www.youtube.com/v/<?php echo $matches[2];?>&hl=en&fs=1"></param>
        <param name="allowFullScreen" value="true"></param>
        <param name="allowscriptaccess" value="always"></param>
        <embed src="http://www.youtube.com/v/<?php echo $matches[2];?>&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed>
           </object>
       <?php
   
}elseif(preg_match("#http://www\.metacafe\.com/watch/(([^/].*)/([^/].*))/?#", $url, $matches)){
       
?>
        <embed flashVars="playerVars=showStats=no|autoPlay=no|videoTitle="  src="http://www.metacafe.com/fplayer/<?php echo $matches[1];?>.swf" width="400" height="348" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"> </embed>
       <?php
   
}
}
$youtubeVideo1 = 'http://in.youtube.com/watch?v=Km7PcdMzaN4';
$youtubeVideo2 = 'http://in.youtube.com/watch?v=xNi7QwAL3XY&feature=dir';
$metacafeVideo1 = 'http://www.metacafe.com/watch/2215104/amazing_video/';
$metacafeVideo2 = 'http://www.metacafe.com/watch/2204556/sensational_cars_of_the_future/';

embedVideo($youtubeVideo1);
embedVideo($youtubeVideo2);
embedVideo($metacafeVideo1);
embedVideo($metacafeVideo2);
?>



Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance.
Categories : HTML, PHP, HTML and PHP, Beginner Guides
Multiple Select box, Select multiple Items from Menu.List box
Categories : PHP, HTML and PHP, Beginner Guides
Newbie Notes #1 - Making a form return to itself
Categories : PHP, Beginner Guides, HTML and PHP
mySQL/PHP/search with multientry form and table output with colored rows
Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases
Form Submission Using Array's
Categories : PHP, HTML and PHP, Beginner Guides, Arrays
Simple PHP Form Field Generator
Categories : PHP, Beginner Guides, Form Processing, HTML and PHP
How to Create a Shoutbox Using PHP & MySQL
Categories : PHP, MySQL, Web Applications, Beginner Guides, HTML and PHP
Kewl Date Example
Categories : PHP, HTML and PHP, Date Time, CSS, Beginner Guides
Newbie Notes #9 - Hyperlinking a post
Categories : PHP, Java Script, HTML and PHP, Beginner Guides
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
PHP based HTML rabbing Tools
Categories : PHP, HTML and PHP, Tag Extractors, Regexps, Beginner Guides
Using PHP im HTML image tags
Categories : PHP, HTML and PHP, Graphics, Beginner Guides
How to preset a text string in a textarea input field
Categories : HTML, HTML and PHP, PHP, Beginner Guides
PHP alternating the colors of table rows with style.
Categories : PHP, HTML and PHP, CSS
PHP function which gets all the data from a webpage into a string, we can perform regular expression functions on that data afterwards to get our desired data.
Categories : PHP, URLs, HTML and PHP