Click Upvote Click Upvote - 1 year ago 122
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?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download