title: Calling member function on array
body: <p>I don't truly understand how chaining functions work on the values that are returned.</p>
  
  <p>Let's say I have a function that returns a string or array</p>
  
  <pre><code>public static $query; 
  
  public static function getArray($arr) {
       Database::$query = $arr;
       return Database::$query;
  }
  
  public function single() {
      return Database::$query[0];
  }
  </code></pre>
  
  <p>Why, when I call it can I then not chain a function onto this to affect the string (In this example I was to append ' test' and how would I go about doing this?</p>
  
  <p>Why can I simply not call</p>
  
  <pre><code>Database::getArray(array("test","test2"))-&gt;single();
  </code></pre>
  
  <p>Without getting a <code>Call to a member function single() on array</code> error. But instead, make it return only the first value of the array.</p>
  
  <p>How would I go append doing what I'm trying to achieve here? Why is my logic wrong?</p>