jsschmitt Posted August 26, 2009 Share Posted August 26, 2009 I have a directory code that I have re-purposed. Here is the issue.. It works exactly as it is suppoused to. x.x I need to to leave off the extensions, so that I can try and see if the code will work, and I can't figure out where to start! <?php $path = './'; $narray = array(); $dir_handle = @opendir($path) or die("Unable to open $path"); $i=0; while($file = readdir($dir_handle)) { if($file != '.' && $file != '..' && $file != 'index.php' ) { $narray[$i]=$file; $i++; } } sort($narray); for($i=0; $i<sizeof($narray); $i++) { echo "@font-face { font-family: ".$narray[$i]."; src: url(".$narray[$i]."); }"; }; //closing the directory closedir($dir_handle); ?> All the files listed are .ttf or .otf... Please... i beg of the PHP gods, help me! Quote Link to comment https://forums.phpfreaks.com/topic/171979-solved-directory-not-include-extension/ Share on other sites More sharing options...
jsschmitt Posted August 26, 2009 Author Share Posted August 26, 2009 Nevermind... I figured it out!! <?php $path = './'; $narray = array(); $dir_handle = @opendir($path) or die("Unable to open $path"); $i=0; while($file = readdir($dir_handle)) { if($file != '.' && $file != '..' && $file != 'index.php' ) { $narray[$i]=$file; $i++; } } sort($narray); for($i=0; $i<sizeof($narray); $i++) { echo "@font-face { font-family: ".substr($narray[$i], 0, -4)."; src: url(".$narray[$i]."); }"; }; //closing the directory closedir($dir_handle); ?> To see what it was for visit: http://anomymage.com/tests/do/snippets/font/ Quote Link to comment https://forums.phpfreaks.com/topic/171979-solved-directory-not-include-extension/#findComment-906826 Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 $narray[$i]=pathinfo($file, PATHINFO_FILENAME); Quote Link to comment https://forums.phpfreaks.com/topic/171979-solved-directory-not-include-extension/#findComment-906828 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.