Inspectopedia
 
2024.3

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

Info
New
Last modified: 03 December 2024

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.