What are some best practices for handling language packs and configuration arrays in PHP without relying on global variables?

When handling language packs and configuration arrays in PHP without relying on global variables, it is best to encapsulate them within a class or use dependency injection to pass them where needed. This helps in keeping the code modular, testable, and easier to maintain.

class LanguagePack {
    private $language;

    public function __construct($language) {
        $this->language = $language;
    }

    public function translate($key) {
        // logic to retrieve translation based on $key and $this->language
    }
}

// Example of how to use the LanguagePack class
$language = 'en';
$languagePack = new LanguagePack($language);
echo $languagePack->translate('hello'); // Output: 'Hello'