0) { while(list ($key) = each ($array_to_search)) { $all_files[] = basename($array_to_search[$key]['path']); //echo basename($array_to_search[$key]['path']).'
'; } } // storing the extension of all the documents in an array // and checking if there is a .jpg, .jpeg, .gif or .png file // if this is the case a slideshow can be made. $all_extensions=array(); $image_present=0; if ( count($all_files) > 0 ) { foreach ($all_files as $file) { $slideshow_extension=strrchr($file,"."); $slideshow_extension=strtolower($slideshow_extension); $all_extensions[]=$slideshow_extension; if (in_array($slideshow_extension,$accepted_extensions)) { $image_present=1; $image_files_only[]=$file; } } } $tablename_column = $_GET['tablename_column']; if($tablename_column==0){ $tablename_column=1; } else{ $tablename_column= intval($tablename_column)-1; } $tablename_direction = $_GET['tablename_direction']; $image_files_only = sort_files($array_to_search); $_SESSION["image_files_only"] = $image_files_only; function sort_files($table){ global $tablename_direction,$accepted_extensions; $temp=array(); foreach($table as $file_array){ if($file_array['filetype']=='file'){ $slideshow_extension=strrchr($file_array['title'],"."); if (in_array($slideshow_extension,$accepted_extensions)) { $temp[] = array('file', basename($file_array['path']), $file_array['size'], $file_array['insert_date']); } } } usort($temp, 'sort_table'); if($tablename_direction == 'DESC'){ rsort($temp); } $final_array=array(); foreach($temp as $file_array){ $final_array[] = $file_array[1]; } return $final_array; } function sort_table($a, $b) { global $tablename_column; if($a[$tablename_column] > $b[$tablename_column]){ return 1; } else{ return -1; } } ?>