i even tried on file time stamps too
im reading in the data from the file dir listing just fyi.
i figure it be better to sort my YY then MMM but i have no idea how to do that.
thank you in advance for any code or help you may provide
The file names are formatted wrong for date sorting. You need to use the ISO-8601 format for something like this. ISO-8601 goes from left-to-right with greater values (years) at the left, and lesser values (seconds) at the rightmost position. All the components are numbers. You can omit any of the positions at the right, so long as you preserve the positions at the left. Example:
'NewsletterDec10.pdf' should be 'Newsletter2010-12.pdf'
<?php // RAY_temp_pern.phperror_reporting(E_ALL);echo "<pre>";// REQUIRED FOR PHP 5.1+date_default_timezone_set('America/Chicago');$list = <<<LISTNewsletterMar12.pdfNewsletterSep11.pdfNewsletterMar11.pdfNewsletterOct11.pdfNewsletterSep10.pdfNewsletterOct10.pdfNewsletterNov11.pdfNewsletterNov10.pdfNewsletterJun11.pdfNewsletterMay11.pdfNewsletterMay10.pdfNewsletterJun10.pdfNewsletterMar10.pdfNewsletterAug11.pdfNewsletterJul11.pdfNewsletterJul10.pdfNewsletterJan12.pdfNewsletterJan11.pdfNewsletterFeb12.pdfNewsletterJan10.pdfNewsletterFeb11.pdfNewsletterDec11.pdfNewsletterFeb10.pdfNewsletterDec10.pdfNewsletterApr11.pdfNewsletterApr10.pdfNewsletterAug10.pdfLIST;// MAKE AN ARRAY$arr = explode(PHP_EOL, $list);// CONVERT THE DATES TO SOMETHING SENSIBLE FOR SORTINGforeach ($arr as $pdf){ $str = str_replace('Newsletter', NULL, $pdf); $str = str_replace('.pdf', NULL, $str); $str = substr($str,0,3) . ' 1, 20' . substr($str,3); $dat = date('c', strtotime($str)); $out[$dat] = $pdf;}// ORDER THE LIST BY MOST RECENTkrsort($out);print_r($out);
The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.
One of a set of tools we're offering as a way of saying thank you for being a part of the community.
@Ray_Paseur
you really need to make a few books, one for from scratch, not knowing a thing about php.
you always think of how to make things better and how they SHOULD be.
thanks for the help Ray_Paseur. Im going to go with sudaraka solution as his was first and used my code, although as i said i like yours too.
Thank you both im very grateful for the help.
@sudaraka
it looks like i sort of had it, just was missing a few more items of code and had the preg_match wrong too.i would of never got it with my code it looks like. but i seamed to of been on the right track. Thanks
(Please note the Y2K bug)
Open in new window