.. _performances-substrinloops: .. _substr()-in-loops: Substr() In Loops +++++++++++++++++ Successive `substr() `_ calls may be replaced by a call to `str_split() `_. It speeds up the processing, and allows the replacement of indefinite loops by a `foreach() `_ call. This is a micro optimisation. It works better on longer strings. .. code-block:: php Suggestions ___________ * Use str_split() Specs _____ +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Short name | Performances/SubstrInLoops | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Rulesets | :ref:`All `, :ref:`Changed Behavior `, :ref:`Performances ` | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Exakat since | 2.5.2 | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | PHP Version | All | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Severity | Minor | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Time To Fix | Quick (30 mins) | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Precision | Medium | +--------------+--------------------------------------------------------------------------------------------------------------------------+ | Available in | `Entreprise Edition `_, `Exakat Cloud `_ | +--------------+--------------------------------------------------------------------------------------------------------------------------+