Inspectopedia Help

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

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.

Inspection Details

By default bundled with:

PhpStorm 2024.1, Qodana for PHP 2024.1,

Can be installed with plugin:


Last modified: 29 April 2024