<?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....

    echo preg_replace('%(.+)\\..*$%', '$1', $filename);
      <? echo("<br>"); ?>
      <? 
      $split = explode('.', $imgArray[$randval]);
      $filename_without_extension = $split[0];
      echo $filename_without_extension;
      ?>
      <? echo("<br>"); ?>
      

      SOLVED

        assuming you will never have a file called picture.with.dots.jpg

        you better do array_pop and implode if you don't like preg

          but what if : string.name.jpg ?

          SOLUTION IS

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

            and who tlls you that the extension always is exactly 3 chacracters?
            maybe sometimes it's only two, maybe it's four (string.name.jpeg)...

              yes You could do as suggested:

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