Array Sorting Headaches

From: Date: Sun, 18 Apr 2004 13:58:33 +0000
Subject: Array Sorting Headaches
Groups: php.general 
Request: Send a blank email to php-general+get-183762@lists.php.net to get a copy of this message
Greetings everyone : Having a hard time with this one. I have a multi-dim array $foo[$x][$y]['key'], where $x and $y are numeric. Here is some sample data : Array ( [$x] => Array
        (
            [0] => Array
                (
                    [invoiceid] => 11842
                    [product] => myproduct
                    [domain] => foo.net
                    [expires] => February 28, 2004
                )
            [1] => Array
                (
                    [invoiceid] => 10295
                    [product] => myotherproduct
                    [domain] => foo.net
                    [expires] => December 9, 2003
                )
            [2] => Array
                (
                    [invoiceid] => 10202
                    [product] => product1
                    [domain] => foo.bar
                    [expires] => January 19, 2003
                )
            [3] => Array
                (
                    [invoiceid] => 10005
                    [product] => product2
                    [domain] => foo.bar
                    [expires] => December 11, 2002
                )
        )
) I need to filter the results so that I get the latest expiry date for each product. The expires field actually contains a timestamp. So for the sample array above, the resultant array would have only keys 0 and 2, filtering out all the rest. There are around 180+ main entries, with any number of sub entries, but each sub entry has the same four keys. Any ideas? Getting a rather large headache mulling over this. Thanks again, Burhan

« previous php.general (#183762) next »