Re: array_unique() workaround?
| From: | Richard Lynch | Date: | Thu, 15 Nov 2001 16:00:18 +0000 |
| Subject: | Re: array_unique() workaround? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74728@lists.php.net to get a copy of this message | ||
Spunk S. Spunk III wrote:
> I'm working on a script that needs array_unique() but my host is using
> 4.0.4 and it's broken in that build. Does anyone have a good workaround
> for this? I can wait for my host to upgrade but if I release this code, it
> would be better to have the workaround...
>
> I just need a good way to check for dups in an array and remove them. I
> can't get my brain around it...
*IF* 4.0.4 has a working http://php.netarray_flip, you can
do:
$temp = array_flip($array);
$array = array_flip($temp);
This will almost certainly be way more faster than iterating through by
hand.
--
Like music? http://l-i-e.com/artists.htm