<?php
$imgpath = "thumbs";
$imgpath2 = "fullphoto";
$handle = opendir( "$imgpath" );
$handle2 = opendir( "$imgpath2" );

$imgArray = array();

while($file = readdir($handle))
{
if( $file != "." && $file != ".." )
{
array_push( $imgArray, $file );
}
}
closedir( $handle );
closedir( $handle2 );
mt_srand( (double)microtime( ) * 1000000 );
$randval = mt_rand( 0, sizeof( $imgArray ) - 1 );

echo "<td align=center><a href=\"$imgpath2/" . $imgArray[ $randval ] . "\" onclick=\"window.open(this.href, 'popupwindow', 'height=605,width=405,scrollbars,resizable'); return false;\"><BR><img border=0 SRC=\"$imgpath/" . $imgArray[ $randval ] . "\"><br /> </a></td>";?>

How to get filename without extension? to echo it like image headline....

    $fileWithoutExtension = substr($fileName,0,strrpos($fileName,".") + 1);
    

    I believe that should work (may need to get rid of the + 1).

    Hope this helps 😉

      Originally posted by sidney
      i think basename is what your looking for

      ...But that still has the extension, and the path won't be present.

        my mistake speed reading again thought the file without directories was wanted

        weedpacket's right you would need to add the suffix parameter

         $path = "/home/httpd/html/index.php"; 
        $file = basename($path,".php"); 
        

          when I was saying filename I meant the filename of image...random image that I was getting and not the filename
          of that particular php page....

          I wanted to echo random thumb and above it some headline like the filename of that random picture. With click on such random thumb You are getting popup window will full resolution image...

          So, for me the best idea for headline ... was to "echo" the filename of image without jpg extension above the picture like some header or as I said headline...

          Now any sugesstions How I do that?

            this will make it dynamic

             $path = "images/photo1.jpg"; 
            $imagename = basename($path,strrchr($path,".")); 
            echo $imagename; 
              <? echo("<br>"); ?>
              <? 
              $split = explode('.', $imgArray[$randval]);
              $filename_without_extension = $split[0];
              echo $filename_without_extension;
              ?>
              <? echo("<br>"); ?>
              

              but what if : string.name.jpg ?

              SOLUTION IS

              <?echo substr("$imgArray[$randval]", 0, -4); ?>

              SOLVED

                Originally posted by japaja

                SOLUTION IS

                <?echo substr("$imgArray[$randval]", 0, -4); ?>

                SOLVED [/B]

                Um, now what if it's "string.name.jpeg"? ScubaKing22's code was what you were after.

                  or

                  echo preg_replace('%(.+)\\..*$%', '$1', $filename);

                  as mentionied in the other thread

                  i love those crossposters...

                    if file name.string.jpg

                     $path = "images/photo1.jpg"; 
                    $imagename = basename($path,strchr($path,".")); 
                    echo $imagename; 

                      Originally posted by mrhappiness

                      i love those crossposters...

                      hehehe.... me to ;-)

                      what if it's "string.name.jpeg"? As ScubaKing22 suggested:

                      <? 
                      $fileWithoutExtension = substr($imgArray[$randval],0,strrpos($imgArray[$randval],".") + 0);
                      echo $fileWithoutExtension;
                      ?>
                        Write a Reply...