title: cURL keeps running instead of stopping after one request
body: <p>I have a PHP function that interacts with an API via a cURL request. The problem is, once its called it keeps running forever, requesting the same stuff again and again, instead of just making 1 request. It made like a thousand of the same calls in just a few seconds.</p>
  <p>I'm pretty new to curl - could you tell me what am I doing wrong?</p>
  <pre><code>function zapier_send_br($data){
  
          // Create a new cURL resource
          $ch = curl_init(ZAPIER_BR_URL);
          
          // Set up request data to send json via POST
          $fields = array(
              'pp_br' =&gt; array(
                  'token'   =&gt; 'xxx',
                  'data'   =&gt; $data
              )
          );
      
          $payload = json_encode($fields);
      
          // Attach encoded JSON string to the POST fields
          curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
      
          // Set the content type to application/json
          curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
      
          // Return response instead of outputting
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      
          // Execute the POST request
          $result = json_decode(curl_exec($ch));
      
          // Close cURL resource
          curl_close($ch);
      
          return $result;
  
  }
  </code></pre>
  <p>How can I make it so it only runs once (or until a single successful request)?</p>
  <p>The functions runs in a foreach loop, but the loop itself only runs 1-2 times, tested and logged it.</p>
  <p>I have other cURL requests as well on the same page (all behave the same loopy way) - should I perhaps use curl_reset($ch) to make sure they don't interfere with each other?</p>