title: php function pass return to the function again
body: <p>I'm doing in instagram API, and little bit confusing about loop in function.</p>
  
  <p>I try to create code to get all images from instagram user, but the API only give limit to 20 images. And we must do next call to the next page.</p>
  
  <p>I'm using <a href="https://github.com/cosenary/Instagram-PHP-API" rel="nofollow">https://github.com/cosenary/Instagram-PHP-API</a> to my application, and here is the function to get images.</p>
  
  <pre><code>function getUserMedia($id = 'self', $limit = 0)
  {
      $params = array();
  
      if ($limit &gt; 0) {
          $params['count'] = $limit;
      }
  
      return $this-&gt;_makeCall('users/' . $id . '/media/recent', strlen($this-&gt;getAccessToken()), $params);
  }
  </code></pre>
  
  <p>I try to make a call, the return value is</p>
  
  <pre><code>{
  
  "pagination": 
  
  {
  
  "next_url": "https://api.instagram.com/v1/users/21537353/media/recent?access_token=xxxxxxx&amp;max_id=1173734674550540529_21537353",
  "next_max_id": "1173734674550540529_21537353"
  
  }, [.... another result data ....]
  </code></pre>
  
  <p>That the first function result, and produce 20 images.</p>
  
  <p>My Question is:</p>
  
  <ol>
  <li>How to pass return from to that function, to that function again using <em>next_max_id</em> parameter, so it will looping and using that function again?</li>
  <li>How to merge the result to be 1 object array?</li>
  </ol>
  
  <p>I'm sorry about my English and my explanation if not good.</p>
  
  <p>Thank you for your help.</p>