skyer2000 Posted March 1, 2006 Share Posted March 1, 2006 (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! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 1, 2006 Share Posted March 1, 2006 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 Quote Link to comment Share on other sites More sharing options...
skyer2000 Posted March 1, 2006 Author Share Posted March 1, 2006 [!--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? Quote Link to comment Share on other sites More sharing options...
skyer2000 Posted March 2, 2006 Author Share Posted March 2, 2006 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.