note 107332 deleted from function.array-flip by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 21:25:53 +0000 |
| Subject: | note 107332 deleted from function.array-flip by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187887@lists.php.net to get a copy of this message | ||
Note Submitter: jripley at azorus dot com
----
@znailz - I don't think that's doing what you describe, per se...
"It takes a value, gets all keys for that value if it has duplicates, unsets them all, and
returns a reindexed array. "
the array_flip() in fact, overwrites any values that are duplicated as it iterates through the array
(however it does that under the hood... not through actual iteration, I assume, based on the speed
at which array_flip operates); it doesn't "unset them all"
that's all well and good. The end result is as you describe... But, no good for associative
arrays (which you mention... "returns a reindexed array"). To preserve keys, you could
simply array_flip($arr) at the end.
just a thought. It's a good solution, but just caught my eye.