I spend a whole day organizing this information for my company since we are building a multi-lingual platform. If you find any issue, missing language, or incorrect charset please edit the list so it will be more useful in the future. Here is the complete list of all the language locales, names, and charsets.
For PHP array here is the link https://github.com/jerryurenaa/language-list/blob/main/language-list-array.php
for JSON here is the link https://github.com/jerryurenaa/language-list/blob/main/language-list-json.json