Re: Duplicate dates in array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dave Goodchild wrote:
Any ideas on the most efficient way to do it? I am working on using
combinations of array_search, in_array and so on and want to avoid regular
expressions if I can. Many thanks in advance for any suggestions!
If you mean that you only want one date for each month (you'll end up with the last one), then it's very simple:

foreach ($dates as $date) {
   preg_match('/[a-z]{3} \d{4}/i', $date, $m);
   $newDates[$m[0]] = $date;
}

If you're really averse to regex, you could use date('Y-m', strtotime($date)) there instead, but I suspect that would perform far worse.

Arpad

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux