Convert list (array) to associative array in PHP
I want to convert a PHP list (array), i.e.
array("start", "end", "coords")
into an associative array with the right values (just to quickly check for the presence / absence of a key), that is, something like this:
array(
"start" => 1,
"end" => 1,
"coords" => 1
)
Is there a more elegant way to do this than this?
array_fill_keys($ar, 1)
+3
source to share