sepoto Posted July 17, 2011 Share Posted July 17, 2011 foreach ($articles as $article) { $title = str_replace('DSG_Steve:', '', $article['title']); $description = str_replace('DSG_Steve:', '', $article['description']); $lines = explode("\n",wordwrap($title,60)); $title = $lines[0]; echo "{$title}... <a class='feed' href='{$article['link']}' target='_new'>More ></a><br/><br/>"; } I'm looking for the least amount of code that will sort my array $articles by $article['date']; Does anyone know how to do that?Thank you! Link to comment Share on other sites More sharing options...
Gex Posted July 17, 2011 Share Posted July 17, 2011 Aye aye, take a look at the ksort function which sorts an array by the key. If that doesn't do it, PHP has a bunch of sorting functions for sorting arrays. http://uk.php.net/manual/en/function.ksort.phpHope that's what your looking for. Link to comment Share on other sites More sharing options...
Synook Posted July 18, 2011 Share Posted July 18, 2011 If you are getting the articles from a database you could also sort the results when querying. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.