Last active
November 23, 2023 14:41
-
-
Save victory-sokolov/d36666a086d74607fb4bdb90d5748695 to your computer and use it in GitHub Desktop.
PHP Function that returns page language
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getLang(array $request, $default) | |
{ | |
return | |
!empty($request['get']['lang']) ? $request['get']['lang'] : | |
(!empty($request['cookie']['lang']) ? $request['cookie']['lang'] : | |
(!empty($request['session']['lang']) ? $request['session']['lang'] : | |
(!empty($request['server']['HTTP_ACCEPT_LANGUAGE']) ? substr($request['server']['HTTP_ACCEPT_LANGUAGE'], 0, 2) : $default))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment