title: Passing new elements to an array within class and returning its values
body: <pre><code>class Item 
  {
  private $_SomeArray = array();
  private $elementOfanArray;
  
  function __construct()
  {
      $this-&gt;_SomeArray[0]="default message";
      $this-&gt;elementOfanArray=0;    //I am trying to assign empty value to an var
  }
  
  public function getArray()
  {
      return $this-&gt;SomeArray;  //function returning whole array
  }
  public function setArray(elementOfanArray)  //function for adding new element to an array and checking if not empty
  {
  if(!elementOfanArray)
      {
  
      }
  else
      {
          array_push($_SomeArray, elementOfanArray);
  
          $elementOfanArray = 0; //I am trying to assign value after addding element to an array
      }
  }
  
  
  function __destruct(){
      $this-&gt;_SomeArray;
      $this-&gt;elementOfanArray;
  }
  }
  </code></pre>
  
  <p>This is my code but now i am wondering if using "array_push" is right choice as it will get called around 20 times.
  The amount of function calls is not constant so if there will be less values.. i would like to remove them from the array or just immediately dump them.</p>
  
  <p>Another question i got is how should i get my elements out of this class, is there a way of getting whole array with values outside of this class?</p>
  
  <p>Is it even right what i wrote?</p>