Given the following array:
Array
(
[0] => 'lorem ipsum'
[1] => 'dolor sit amet'
[2] => 'consectetur adipiscing elit'
)
What is the best way to convert this to the following:
Array
(
['lorem ipsum'] => true
['dolor sit amet'] => true
['consectetur adipiscing elit'] => true
)
Other than foreach-ing and creating a new array? Is there any built-in PHP function that can do this for me?
The values of the keys in the new array will always be a fixed value, i.e true
.
I looked at array_flip but don't think this will allow me to apply a fixed value.