On Wed, Nov 14, 2001 at 09:17:03AM +0100, 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 you can sort the array, it is quite easy, simply sort it and look for
consecutive values that are equal.

Depending on your values, you might also try array_flip() twice. The
values becomes keys and keys values, and then back again. You will
then have unique values.

Yet another way could be to use array_count_values() perhaps.

Stig

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to