Jump to content

Using PHP to read file names in a directory


calrockx

Recommended Posts

Cool forum, I'm sure I'll be checking this one often, being the PHP "newb" I am, ha.  :)

 

Anyway, I'm working on a page now and I'm using PHP to read the file names in a directory and display those images on a page.

 

	<?php
            $handle = opendir ('./sections/'.$_GET[section].'/_categories/');
            while (false !== ($file = readdir($handle))) {
                if($file != "." && $file != ".." && $file != basename(__FILE__)) {
                    echo '<li><img src="'.$file.'"/></li>';}}
        ?>

 

That script is working just fine now as is - it outputs the file name with extension ("image1.jpg" for example).

I'd like to modify to output the file name without the period and file type attached (just "image1"). 

 

Any ideas?

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.