.. _structures-noarrayunique: .. _avoid-array\_unique(): Avoid array_unique() ++++++++++++++++++++ The native function `array_unique() `_ is much slower than using other alternatives, such as `array_count_values() `_, `array_flip() `_/`array_keys() `_, or even a `foreach() `_ loops. .. code-block:: php See also `array_unique `_.. Connex PHP features ------------------- + `array `_ Suggestions ___________ * Upgrade to PHP 7.2 * Use an alternative way to make values unique in an array, using array_count_values(), for example. Specs _____ +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Short name | Structures/NoArrayUnique | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Changed Behavior `, :ref:`Performances ` | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 0.8.4 | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | PHP Version | With PHP 7.2 and older | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Precision | Very high | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+--------------------------------------------------------------------------------------------------------------------------+