I want to sort gif files in this array.

while($file=readdir($handle)){
  $file_names  = explode(".", $file);            
$extention = $file_names[sizeof($file_names)-1]; if($extention == "gif") $gif_files[] = $file; } closedir($handle); sort($gif_files[]); for($num=0; $num<sizeof($gif_files); $num++){ echo "<img src= \"$filepath".$gif_files[$num]."\" border= '0' class= 'e_list'>\n"; }

the error message is;
"Warning: sort() expects parameter 1 to be array, null given..."

please let me know what I am wrong.

    sort($gif_files[]); 

    Lose the [].

    Oh, and have a look at [man]glob[/man].

      Weedpacket,

      Thank you for your kind instructions.

      Works fine.

        Write a Reply...