PhpStorm
 
Get PhpStorm
You are viewing the documentation for an earlier version of PhpStorm.

Code Inspection: 'array_fill' can be converted to loop

Last modified: 16 May 2022

Reports the array_fill() calls that can be replaced with foreach loops.

The array_fill (php.net) function is used for filling an array with values. You can also use a foreach loop (php.net) to achieve the same result.

In the following example, the myArr array is filled with values by using either the array_fill() function call or the foreach loop.