note 107332 added to function.array-flip
| From: | jripley at azorus dot com | Date: | Tue, 31 Jan 2012 21:20:40 +0000 |
| Subject: | note 107332 added to function.array-flip | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185811@lists.php.net to get a copy of this message | ||
@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.
----
Server IP: 66.207.199.35
Probable Submitter: 24.222.13.228
----
Manual Page -- http://www.php.net/manual/en/function.array-flip.php
Edit -- https://master.php.net/note/edit/107332
Del: integrated -- https://master.php.net/note/delete/107332/integrated
Del: useless -- https://master.php.net/note/delete/107332/useless
Del: bad code -- https://master.php.net/note/delete/107332/bad+code
Del: spam -- https://master.php.net/note/delete/107332/spam
Del: non-english -- https://master.php.net/note/delete/107332/non-english
Del: in docs -- https://master.php.net/note/delete/107332/in+docs
Del: other reasons-- https://master.php.net/note/delete/107332
Reject -- https://master.php.net/note/reject/107332
Search -- https://master.php.net/manage/user-notes.php