At 4/10/2007 03:09 PM, M.Sokolewicz wrote:
Such a function is inherently a Bad Idea (tm). array-values are not unique. Array keys are. So unless you want to emulate the way array_flip works (bad idea (tm)), I'd say: leave it be.


Whoever owns that trademark has totally got to be the wealthiest person in this battered old world~

I guess one could argue that if the array values must be unique then you could use the associative array keys to hold those values; then you can use unset() to remove selected keys which *are* the values. If both keys and values are unique, I'd consider (if only briefly) maintaining two arrays, one a flipped version of the other, so I could look up key/value pairs using either node.

If the values aren't unique and you want to remove all array elements with a given value, you might use array_walk().

Flipping the array back and forth just to unset individual elements seems extremely inefficient. Besides, if the element values aren't unique, won't flipping the values & keys eliminate array elements that share the same value?

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to