title: How to build an array that will be updated across many methods
body: <p>I have to check if an element id is duplicate and if so update it with a "-1".</p>
  
  <pre><code>//get all elements and loop through each element
  public function main(){
      $products = $this-&gt;getProducts();
      foreach($products as $product){
          $formatted_products = $this-&gt;processProducts($product);
      }
  }
  public function processProducts($product){
  
      //builds a csv with product data
      'id' =&gt; $this-&gt;duplicateSkus($product-&gt;getSku());
  
      if($product-&gt;getTypeId() == "configurable"){
          $csv = $this-&gt;getVariants($csv, $product);
      }
  }
  
  public function getVariants($csv, $product){
      'id' =&gt; $this-&gt;duplicateSkus($childProduct-&gt;getSku())
  }
  
  //my main method where I check if ids are unique
  public function duplicateSkus($product_sku){
      if(in_array($product_sku, $products_sku)){
          $product_sku = $product_sku."-1";
      }
      $products_sku[] = $product_sku;
      return $product_sku;
  
  }
  </code></pre>
  
  <p>My issue is with building an array <code>$products_sku</code> with all ids and check each one against it. </p>
  
  <p>Thanks!</p>