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

Code Inspection: Using 'count()' as index for appending value to array

Last modified: 16 May 2022

Reports the count($array) calls that are used as an array index for appending an element to the array: $array[count($array)] = 42. In such cases, it is recommended to use square bracket syntax ($array[] = 42) instead, which adds no overhead of calling a function.