iOS推送不会使用多个设备ID

I am fetching an array of device_ids using PHP, and sending iOS pushes to each of them with this code -
Question - the devices received pushes when array of device_ids (deviceTokens) was 2-3 device_ids. But deviecs did not receive push notifications when deviceTokens array was ~300 device_id long. What could be the issue? I am new to PHP

(This question has been asked a few times but answers did not reflect problem I am facing)

$customers_ios = "SELECT * FROM `gcm_user` WHERE `gcmregios` <> '0' and `preference` = '1'";
                $c_ios = mysql_query($customers_ios);

                while($bd = mysql_fetch_array($c_ios)) {
                    $deviceTokens[]= $bd['gcmregios'];

                }

                $arrlength = count($deviceTokens);
                //echo $arrlength;

                // Put your private key's passphrase here:
                $passphrase = 'mypassphrase';//'PushNotification';

                //adhoc_id already setup above
                $message = $adhoc_desc;
                $title =  $adhoc_title;



                $ctx = stream_context_create();
                stream_context_set_option($ctx, 'ssl', 'local_cert', 'PushDistCertificates.pem');
                stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);

                //'ssl://gateway.sandbox.push.apple.com:2195'
                // Open a connection to the APNS server
                $fp = stream_socket_client(
                  'ssl://gateway.push.apple.com:2195', $err,
                  $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

                if (!$fp)
                    continue;

                // Create the payload body
                $body['aps'] = 
                array(
                    'alert'=> $title,
                    'message' => 
                    array('ADHOC' => 
                        array('ADHOC_ID' => $adhoc_id,
                            'ADHOC_TITLE' => $title,
                            'ADHOC_DESCRIPTION' =>  $message,
                        )
                    ),
                    'sound'=>'default'
                );

                // Encode the payload as JSON
                $payload = json_encode($body);

                foreach($deviceTokens as $ios_token){
                    $msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $ios_token)) . pack("n",strlen($payload)) . $payload;
                    $result = fwrite($fp, $msg); 
                }
                // Close the connection to the server
                fclose($fp);

Similar issues we had , Cross checking all device id in the database we found device id as "Simulator" which is device id of virtual device in the xcode. During development DEV team might have tested in Simulator and sooner APNS identifies this id , it rejects all request. May be specific issues only to us , cross checking will help.