tibberous Posted December 20, 2007 Share Posted December 20, 2007 I needed to soft files by their extension. $dir = opendir($path); $files = array(); function sortByExt($x, $y){ return strcmp($x['ext'], $y['ext']); } while($file = readdir($dir)){ if($file == '.' || $file == '..') continue; $ext = explode('.', $file); $ext = array_pop($ext); $files[] = array('file'=>$file, 'ext'=>$ext); } usort($files, "sortByExt"); I was thinking there was a way to do it without usort, just like a 'sort by value' kind of thing. Quote Link to comment Share on other sites More sharing options...
Jessica Posted December 20, 2007 Share Posted December 20, 2007 That's how I'd do it, that's what usort is for. Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted December 20, 2007 Share Posted December 20, 2007 That's what it's used for. You did good. 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.