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! 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/ 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); 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
Archived
This topic is now archived and is closed to further replies.