Re: Duplicate dates in array
| From: | Arpad Ray | Date: | Mon, 02 Apr 2007 13:06:33 +0000 |
| Subject: | Re: Duplicate dates in array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251923@lists.php.net to get a copy of this message | ||
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