Jump to content

[SOLVED] Directory... not include extension


jsschmitt

Recommended Posts

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

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/

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.