why dont you keep it simple and clean
<?php
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
$acceptLang = ['fr', 'it', 'en'];
$lang = in_array($lang, $acceptLang) ? $lang : 'en';
require_once "index_{$lang}.php";
?>
More Related Contents:
- How to write specific CSS for mozilla, chrome and IE
- PHP mobile browser detection?
- reliable user browser detection with php
- Sending correct file size with PHP download script
- Turning an Object into a string in PHP
- How i can earn variable from string in PHP? [closed]
- What does the PHP error message “Notice: Use of undefined constant” mean?
- Showing all errors and warnings [duplicate]
- Apache shows PHP code instead of executing it
- How to rename uploaded file before saving it into a directory?
- How to encrypt/decrypt data in php?
- How to pass $_GET variables from a link to a bootstrapmodal?
- FPDF error: Some data has already been output, can’t send PDF
- A form doesn’t submit [duplicate]
- Safely catch a ‘Allowed memory size exhausted’ error in PHP
- Laravel-5 ‘LIKE’ equivalent (Eloquent)
- php array behaving strangely with key value 07 & 08
- How to store NULL values in datetime fields in MySQL?
- UTF-8 encoded html pages show � (questions marks) instead of characters
- What does this mean? “Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM”
- How to send 500 Internal Server Error error from a PHP script
- PHP how to retrieve array values
- Creating csv file with php
- Enabling $_GET in codeigniter
- How to check if a specific value exists at a specific key in any subarray of a multidimensional array?
- php share variable among different users/sessions
- When to pass-by-reference in PHP
- PCRE regular expression overlapping matches
- Convert hex color to RGB values in PHP
- file_get_contents returns empty string