Jump to content


Photo

If state using file extensions


  • Please log in to reply
3 replies to this topic

#1 skyer2000

skyer2000
  • Members
  • PipPipPip
  • Advanced Member
  • 114 posts

Posted 01 March 2006 - 08:53 PM

(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!

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 01 March 2006 - 09:12 PM

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

Ken

#3 skyer2000

skyer2000
  • Members
  • PipPipPip
  • Advanced Member
  • 114 posts

Posted 01 March 2006 - 11:09 PM

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

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?

#4 skyer2000

skyer2000
  • Members
  • PipPipPip
  • Advanced Member
  • 114 posts

Posted 02 March 2006 - 01:01 AM

got it,

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

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users