ztealmax Posted December 13, 2006 Share Posted December 13, 2006 Hi, im sorry but im having alot of problems today, got this source that makes a filelist of files in a foldersorted by date, however it seems to sort it by name instead:So plainly, whats wrong with my code: ;)Im full with stupid questions today hehehe ;D[code]<?php $this = $PHP_SELF; $dir = $DOCUMENT_ROOT."x101_news/"; $files = opendir($dir); $file_list = array(); $file_sort = array(); if(empty($sort))$sort="name"; if(empty($r)) $r=0; $cnt = 1; while ($file = readdir($files)) { $full_path = $dir."/".$file; if(!is_dir($full_path)) { $ext = explode(".",$file); $i=count($ext); if($i>1)$file_details["ext"] = strtolower($ext[$i-1]); $file_details["name"] = $ext[0]; $file_details["date"] = filectime($full_path); $file_list[$cnt] = $file_details; $key = strtolower($file_details[$sort]); $file_sort[$cnt] = $key; $cnt++; } } if($r)arsort($file_sort); else asort($file_sort); ?><link href="../webmax.css" rel="stylesheet" type="text/css"><table width="465" border="0" cellpadding="3" cellspacing="0" class="bodytext"> <tr> <td width="174"><a href="<?php print($this);?>?sort=name&r=<?php print(!$r);?>">Name</a></td> <td width="141"><a href="<?php print($this);?>?sort=date&r=<?php print(!$r);?>">Date</a></td> </tr> <tr bgcolor="#0033CC"> <td height="3" colspan="5"> </td> </tr><?php while(list($key, $value)=each($file_sort)){ $value = $file_list[$key];?> <tr> <td width="174"><a href="read.php?text=x101_news/<?php print($value["name"]);?>"><?php print($value["name"]);?></a></td> <td width="141"><?php print(date("Y/m/d H:i",$value["date"]));?></td> </tr><?php}?></table>[/code]Im sorry i fix it ;) lol stupid me, shouldnt code when im tiered Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.