How can global associative arrays be used to store language variables in PHP?

Global associative arrays can be used to store language variables in PHP by creating an array that holds key-value pairs where the key represents the language variable name and the value represents the corresponding text in that language. This allows for easy access and management of language variables throughout the application.

// Define a global associative array to store language variables
$language = array(
    'greeting' => 'Hello',
    'welcome' => 'Welcome to our website',
    'goodbye' => 'Goodbye, see you soon'
);

// Access language variables using array keys
echo $language['greeting']; // Output: Hello
echo $language['welcome']; // Output: Welcome to our website
echo $language['goodbye']; // Output: Goodbye, see you soon