Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6244577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:21:01+00:00 2026-05-24T12:21:01+00:00

I came across a script that parses HTTP_ACCEPT_LANGUAGE: http://www.thefutureoftheweb.com/blog/use-accept-language-header this script returns an ORDERED

  • 0

I came across a script that parses HTTP_ACCEPT_LANGUAGE: http://www.thefutureoftheweb.com/blog/use-accept-language-header

this script returns an ORDERED array containing the acceptable langs:

Array
(
[it] => 1
[ar] => 0.8
[ja] => 0.6
[cn] => 0.4
[de] => 0.2
)

Now, I want to make an array containing the available languages like that:

$av_lang = array(‘en’,’fr’,’de’,’it’); (unordered array)

Then I want to loop through the first array and get the first key that is in the second array.

For example, it takes ‘en’ from the first array and check if present in the second array, if not, go to the next key ‘ar’ and check it. if none of them, return a default lang like ‘en’.

Finally I want to get one of the available langs in $av_lang.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T12:21:02+00:00Added an answer on May 24, 2026 at 12:21 pm

    Try something like this:

    $lang = array('it' => 1, 'ar' => 0.8, 'ja' => 0.6, 'cn' => 0.4, 'de' => 0.2);
    $preferred = array('en', 'ja');
    
    $intersect = array_values(array_intersect(array_keys($lang), $preferred));
    
    if (isset($intersect[0])) {
        echo $intersect[0]; // returns ja
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across an article about Car remote entry system at http://auto.howstuffworks.com/remote-entry2.htm In the
Awhile ago I came across a script that basically fetched a list of countries/states
I recently came across this site. http://beta.rallyinteractive.com/ . The site uses some fairly complex/awesome
While working on a project, I came across a JS-script created by a former
On my current project, I came across our master DB script. Taking a closer
I came across a printed article by Bertrand Meyer where he states that tests
I came across a controller in an older set of code (Rails 1.2.3) that
I came across a design that overrides [Scriptable.put][1] in a subclass of ScriptableObject to
I'm using a shopping cart script from a tutorial I came across a while
on my quest to learn and improve my JavaScript I came across a script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.