1.2.311. Count() To Array Append¶
The array append operator is able to generate a sane index, without relying on the count() function. This is faster, and safer.
<?php
$newArray = [];
foreach($array as $value) {
// count is overkill here
$newArray[count($newArray)] = $value;
}
?>
1.2.311.1. Connex PHP features¶
1.2.311.1.1. Suggestions¶
Remove the call to count()
1.2.311.1.2. Specs¶
Short name |
Performances/CountToAppend |
Rulesets |
|
Exakat since |
2.6.2 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Medium |
Available in |