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
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/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.