...using array_combine() instead of a foreach.

Comments

Status: Needs review » Needs work

The last submitted patch failed testing.

catch’s picture

Status: Needs work » Needs review
StatusFileSize
new796 bytes

array_combine() doesn't like empty arrays.

dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks.

chx’s picture

Status: Fixed » Needs review
StatusFileSize
new727 bytes

Hmm, this is broken because for empty arrays it return NULLs. Second, why not array_walk then?

catch’s picture

Both 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.

damien tournoud’s picture

This is a duplicate of #280058: Refactor drupal_map_assoc() where other issues of this approach have been identified...

catch’s picture

StatusFileSize
new795 bytes

Damn, 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.

chx’s picture

I 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.

dries’s picture

Status: Needs review » Needs work

Reverted in CVS HEAD. Thanks.

sun’s picture

Status: Needs work » Closed (duplicate)

Marking as duplicate of #280058: Refactor drupal_map_assoc()

devsaran’s picture

Status: Closed (duplicate) » Needs review

drupal_map_assoc.patch queued for re-testing.

webchick’s picture

Status: Needs review » Closed (duplicate)