diff --git a/core/ArrayLib.php b/core/ArrayLib.php index 19df498cd..6195fe2b0 100755 --- a/core/ArrayLib.php +++ b/core/ArrayLib.php @@ -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); } /** diff --git a/tests/ArrayLibTest.php b/tests/ArrayLibTest.php index 4839e4e0e..f67765f7d 100644 --- a/tests/ArrayLibTest.php +++ b/tests/ArrayLibTest.php @@ -30,4 +30,20 @@ class ArrayLibTest extends SapphireTest { ) ); } + + function testValuekey() { + $this->assertEquals( + ArrayLib::valuekey( + array( + 'testkey1' => 'testvalue1', + 'testkey2' => 'testvalue2' + ) + ), + array( + 'testvalue1' => 'testvalue1', + 'testvalue2' => 'testvalue2' + ) + ); + } + } \ No newline at end of file