public static function makeValuePairs($array, $key, $value)
{
$tempArray = [];
if (is_array($array)) {
foreach ($array as $item) {
if (empty($key)) {
$tempArray[] = $item[$value];
} else {
$tempArray[$item[$key]] = $item[$value];
}
}
}
return $tempArray;
}
public function testMakeValuePairs() { $test = array(array('id' => 1, 'value' => 1), array('id' => 2, 'value' => 2)); $this->assertEquals(array(1 => 1, 2 => 2), Arr::makeValuePairs($test, 'id', 'value')); $this->assertEquals(array(0 => 1, 1 => 2), Arr::makeValuePairs($test, '', 'value')); }