array_column() To Hash

../_images/array_column_to_hash.png

array_column() is a very handy PHP native function, which extracts a index from a list of arrays, or a public property from a list of objects.

The third argument of array_column() is a key, which will be used to reference the value in the resulting array. It is very convenient to turn an array into a hash.

Note that duplicate keys will be overwritten.

Also, there is no reciprocal function for this: turn a hash into an array of arrays or objects.

See Also

PHP Features