title: PHP code to send Android push notification to multiple device
body: <p>Below is the code for php in which i make a curl call to the GCM server:</p>
  
  <pre><code>//CODE TO SEND PUSH NOTIFICATION 
                          define('API_ACCESS_KEY', 'XXXXXXXXXXXXXXXXXXXXX');
                          $i = 0;
                          $result1 = mysql_query("SELECT * FROM `my_devices`") or die($log-&gt;lwrite("Error" . mysql_error()));
                          while ($row2 = mysql_fetch_array($result1)) {
                              $i = $i + 1;
                              $msg = array(
                                  'message' =&gt; $resultTextValue
                              );
  
                              $fields = array(
                                  'registration_ids' =&gt; array($row2['gcmId']),
                                  'data' =&gt; $msg
                              );
  
                              $headers = array(
                                  'Authorization: key=' . API_ACCESS_KEY,
                                  'Content-Type: application/json'
                              );
  
                              $ch = curl_init();
                              curl_setopt($ch, CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
                              curl_setopt($ch, CURLOPT_POST, true);
                              curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                              curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                              curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
                              $result = curl_exec($ch);
                              curl_close($ch);
                          }
  </code></pre>
  
  <p>My code is under development and has max of 10 device registered. So it take decent time to make send the notificaiton to all the device.</p>
  
  <p>My concern is: when the app is deployed I will be having thousands of device to send the push notification. <strong>Won't it take a big amount of time for the push notification call?</strong></p>
  
  <p>I am new to PHP and copied the above code from some sample application.</p>