Create an assoc array with equal keys and values from a regular array

Solution 1:

You can use the array_combine function, like so:

$numbers = array('first', 'second', 'third');
$result = array_combine($numbers, $numbers);

Solution 2:

This simple approach should work:

$new_array = array();
foreach($numbers as $n){
  $new_array[$n] = $n;
}

You can also do something like:

array_combine(array_values($numbers), array_values($numbers))