1.2.59. Autoappend¶
Appending a variable to itself leads to enormous usage of memory.
<?php
// Always append a value to a distinct variable
foreach($a as $b) {
$c[] = $b;
}
// This copies the array to itself, and double the size each loop
foreach($a as $b) {
$c[] = $c;
}
?>
1.2.59.1. Suggestions¶
Change the variable on the left of the append
Change the variable on the right of the append
1.2.59.2. Specs¶
Short name |
Performances/Autoappend |
Rulesets |
|
Exakat since |
1.8.3 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |