...using array_combine() instead of a foreach.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | drupal_map_assoc.patch | 795 bytes | catch |
| #4 | array_walk.patch | 727 bytes | chx |
| #2 | drupal_map_assoc.patch | 796 bytes | catch |
| drupal_map_assoc.patch | 723 bytes | catch |
...using array_combine() instead of a foreach.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | drupal_map_assoc.patch | 795 bytes | catch |
| #4 | array_walk.patch | 727 bytes | chx |
| #2 | drupal_map_assoc.patch | 796 bytes | catch |
| drupal_map_assoc.patch | 723 bytes | catch |
Comments
Comment #2
catcharray_combine() doesn't like empty arrays.
Comment #3
dries commentedCommitted to CVS HEAD. Thanks.
Comment #4
chx commentedHmm, this is broken because for empty arrays it return NULLs. Second, why not array_walk then?
Comment #5
catchBoth more better, and more shorter. chx reminds me we don't have unit tests for this - won't get to them tonight but will work some up.
Comment #6
damien tournoud commentedThis is a duplicate of #280058: Refactor drupal_map_assoc() where other issues of this approach have been identified...
Comment #7
catchDamn, I even posted on that issue but had completely forgotten it was there.
So we should probably revert this and continue where that left off. Here's a patch to do that. Apologies all.
Comment #8
chx commentedI would go with #4. The issue identified in the duplicate is that array_combine is more useable than the current implementation because it casts to string every key so 1.5 does not become 1 as an array key. The only question is whether we want array_walk or array_map.
Comment #9
dries commentedReverted in CVS HEAD. Thanks.
Comment #10
sunMarking as duplicate of #280058: Refactor drupal_map_assoc()
Comment #11
devsaran commenteddrupal_map_assoc.patch queued for re-testing.
Comment #12
webchick