Jump to content

Archived

This topic is now archived and is closed to further replies.

skyer2000

If state using file extensions

Recommended Posts

(sorry title is supposed to read "If statement using file extensions")

I'm trying to figure this out for my media website. I've got 2 types of videos to display, either .flv or .wmv. What I'm trying to figure out is a "if" statement i could use so that if the file ends in .wmv, it will display one way, else it will display another way for the .flv files.

Thanks in advance!

Share this post


Link to post
Share on other sites
Use the [a href=\"http://www.php.net/pathinfo\" target=\"_blank\"]pathinfo[/a]() function to get the extension:
[code]<?php
$pi = pathinfo($filename);
switc $pi['extenson'] {
   case 'flv':
//
// do the flv processing
//
   break;
   case 'wmv':
//
// do the wmv processing
//
   break;
}
?>[/code]

Ken

Share this post


Link to post
Share on other sites
[!--quoteo(post=350780:date=Mar 1 2006, 04:12 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 1 2006, 04:12 PM) [snapback]350780[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Use the [a href=\"http://www.php.net/pathinfo\" target=\"_blank\"]pathinfo[/a]() function to get the extension:
[code]<?php
$pi = pathinfo($page['url']);
switch($pi['extenson']) {
   case 'wmv':
//
// do the wmv processing
//
   break;
   case 'flv':
//
// do the flv processing
//
   break;
}
?>[/code]

Ken
[/quote]

I had to edit the code a tad to get rid of errors, but now it just displays the page without anything between the "case 'wmv';" and the first "break", even when the $page['url'] calls up the filename (movie.wmv). Any ideas?

Share this post


Link to post
Share on other sites
got it,

[code] <? $fileend=substr($page['url'],-3);

switch($fileend) {
   case "wmv":
//
// do the wmv processing
//
break;
   case "flv":
//
// do the flv processing
//
break;
}
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.