1.2.58. 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.58.1. Suggestions

  • Change the variable on the left of the append

  • Change the variable on the right of the append

1.2.58.2. Specs

Short name

Performances/Autoappend

Rulesets

All, Changed Behavior, Performances

Exakat since

1.8.3

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

Very high

Available in

Entreprise Edition, Exakat Cloud