What is the MOST EFFICIENT way to have an array of values and turn it into an array of keys? I'd really like to avoid any foreach loop...
$in = array(
'red',
'green',
'blue'
);
INTO
$out = array(
'red' => NULL,
'green' => NULL,
'blue' => NULL
);
Use PHP's
array_flip
function.On second thought, if you want the values to be null, then you might want to use
array_fill_keys
: