title: CSE Google Custom Page api show 50 results PHP?
body: <p>I'm trying to get the first 50 results of the Google CSE API with the following PHP code.</p>
  
  <p>The problem is that it combines the two pages sow the results are getting messed up like the first position is the one of the first page and the second position is the second of the second page and so on. Can someone tell me what I am doing wrong here?</p>
  
  <p>What I actually want to do is get the first 50 results in a array, but the code below gives me mixed results.</p>
  
  <pre><code>$apiKey = "theapikey";
  
  $query = "news";
  
  for ($i = 1; $i &lt;= 5; $i++) {
  
  $ch = curl_init();
  
   $request = "https://www.googleapis.com/customsearch/v1?q=" . urlencode( "$query" ) . "&amp;cx=013594553343653397533:q-qkkaltmay" ."&amp;key=" . $apiKey . "&amp;start=" . $i;
  
  curl_setopt($ch, CURLOPT_URL, $request);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  
  $output = curl_exec($ch);
  $output = json_decode($output);
  
  foreach( $output-&gt;items as $result ) {
  
      $url = $result-&gt;link;
  
      ${"items" . $i}[] = $url;
  
    } 
  
  }
  
    echo json_encode($items1);
  </code></pre>