.. _structures-couldusearrayfillkeys: .. _could-use-array\_fill\_keys: Could Use array_fill_keys +++++++++++++++++++++++++ `array_fill_keys() `_ is a native PHP function that creates an array from keys. It gets the list of keys, and a constant value to assign to each keys. This is twice faster than doing the same with a loop. Note that is possible to use an object as initializing value : every element of the final array will be pointing to the same value. And, also, using an object as initializing value means that the same object will be used for each key : the object will not be cloned for each value. .. code-block:: php See also `array_fill_keys `_. Suggestions ___________ * Use array_fill_keys() Specs _____ +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/CouldUseArrayFillKeys | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Suggestions ` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 1.1.7 | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Slow (1 hour) | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Examples | :ref:`case-churchcrm-structures-couldusearrayfillkeys`, :ref:`case-phpipam-structures-couldusearrayfillkeys` | +--------------+-------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+-------------------------------------------------------------------------------------------------------------------------+