mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Use array_combine() instead of custom logic for ArrayLib::valuekey() (thanks paradigmincarnate!)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@107380 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
eccf44ec64
commit
a10bb202af
@ -62,11 +62,7 @@ class ArrayLib {
|
||||
* @return array
|
||||
*/
|
||||
static function valuekey($arr) {
|
||||
$newArr = array();
|
||||
foreach($arr as $val) {
|
||||
$newArr[$val] = $val;
|
||||
}
|
||||
return $newArr;
|
||||
return array_combine($arr, $arr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,4 +30,20 @@ class ArrayLibTest extends SapphireTest {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function testValuekey() {
|
||||
$this->assertEquals(
|
||||
ArrayLib::valuekey(
|
||||
array(
|
||||
'testkey1' => 'testvalue1',
|
||||
'testkey2' => 'testvalue2'
|
||||
)
|
||||
),
|
||||
array(
|
||||
'testvalue1' => 'testvalue1',
|
||||
'testvalue2' => 'testvalue2'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user