How can the issue of sending global messages to all users be efficiently resolved in a PHP system with text-based data storage?

Issue: To efficiently send global messages to all users in a PHP system with text-based data storage, you can create a function that retrieves all user data from the text-based storage and then sends the message to each user individually.

// Function to send global message to all users
function sendGlobalMessage($message) {
    $users = file_get_contents('users.txt'); // Assuming users are stored in a text file
    $usersArray = explode("\n", $users);
    
    foreach ($usersArray as $user) {
        // Send message to each user
        echo "Sending message to: $user - $message\n";
        // Code to actually send message to user goes here
    }
}

// Usage
$message = "This is a global message for all users.";
sendGlobalMessage($message);