Click Upvote Click Upvote - 3 months ago 39
PHP Question

PHP function for swapping array indexes and values

Is there a function which makes




And also, is there a limit on what characters can go inside an array index?


array_flip() exchanges all keys with their associated values in an array. Any characters can be used in the key, however keep in mind that keys must be unique, so:

$array = array_flip($array);

Yields only:

    [Color] => red