How to send push notifications to multiple devices using php script using FCM?

If you were to send notification via terminal the data part of the curl command would look like this:

{
"registration_ids": ["device_token_1", "device_token_2"],
"notification": {
    "body": "Hello",
    "title": "Hello",
    "vibrate": 1,
    "sound": 1
 }
}

PHP code:

$body = array(
        'registration_ids' => array("device_token_1", "device_token_2"),
        'notification' => array('body' => 'Hello', 'title' => 'Hello', 'vibrate' => 1, 'sound' => 1)
    );

Try to send device ID of multiple devices as an array. In your case,

$registration_ids must be an array of device IDs.

E.g

$registration_ids = array('Device ID 1', 'Device ID 2');

Use 'registrations_ids' in place of 'to', if you want to send to the multiple users like:

$fields = array
(
    'registration_ids'  => $tokens,
    'notification'   => $msg


);

where $tokens = array("device token 1" , "device token 2");

if you want to send to the single user use 'to' , like

$fields = array
(
    'to'  => $token,
    'notification'   => $msg


);

where $token = "device token 1";