glenelkins Posted February 28, 2006 Share Posted February 28, 2006 what function is there to test the extension of a file? Link to comment https://forums.phpfreaks.com/topic/3742-getting-the-extension-of-a-file/ Share on other sites More sharing options...
litebearer Posted February 28, 2006 Share Posted February 28, 2006 Might take a look here...[a href=\"http://codewalkers.com/seecode/95.html\" target=\"_blank\"]http://codewalkers.com/seecode/95.html[/a]Lite... Link to comment https://forums.phpfreaks.com/topic/3742-getting-the-extension-of-a-file/#findComment-12989 Share on other sites More sharing options...
obsidian Posted February 28, 2006 Share Posted February 28, 2006 [!--quoteo(post=350185:date=Feb 28 2006, 07:17 AM:name=glenelkins)--][div class=\'quotetop\']QUOTE(glenelkins @ Feb 28 2006, 07:17 AM) [snapback]350185[/snapback][/div][div class=\'quotemain\'][!--quotec--]what function is there to test the extension of a file?[/quote]you can write one:[code]<?phpfunction getExt($filename) { $pos = strrpos($filename, '.'); if ($pos !== false) { return substr($filename, $pos + 1); } else return NULL; }?>[/code] Link to comment https://forums.phpfreaks.com/topic/3742-getting-the-extension-of-a-file/#findComment-12994 Share on other sites More sharing options...
glenelkins Posted February 28, 2006 Author Share Posted February 28, 2006 in the other example (linked site) they use a function called: strch() but that returns an undefined error wierd Link to comment https://forums.phpfreaks.com/topic/3742-getting-the-extension-of-a-file/#findComment-13025 Share on other sites More sharing options...
kenrbnsn Posted February 28, 2006 Share Posted February 28, 2006 Look at the [a href=\"http://www.php.net/pathinfo\" target=\"_blank\"]pathinfo[/a]() function.Example from the manual:[code]<?php$path_parts = pathinfo('/www/htdocs/index.html');echo $path_parts['dirname'], "\n";echo $path_parts['basename'], "\n";echo $path_parts['extension'], "\n";?> [/code]Ken Link to comment https://forums.phpfreaks.com/topic/3742-getting-the-extension-of-a-file/#findComment-13027 Share on other sites More sharing options...
obsidian Posted February 28, 2006 Share Posted February 28, 2006 [!--quoteo(post=350239:date=Feb 28 2006, 10:34 AM:name=glenelkins)--][div class=\'quotetop\']QUOTE(glenelkins @ Feb 28 2006, 10:34 AM) [snapback]350239[/snapback][/div][div class=\'quotemain\'][!--quotec--]in the other example (linked site) they use a function called: strch() but that returns an undefined error wierd[/quote]they are trying to use strchr(), but it's simply an alias of strstr() anyway Link to comment https://forums.phpfreaks.com/topic/3742-getting-the-extension-of-a-file/#findComment-13028 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.