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

  • SEARCH
  • Home
  • 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 6391811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:44:06+00:00 2026-05-25T03:44:06+00:00

I have these three sub arrays, I would like to make one array that

  • 0

I have these three sub arrays, I would like to make one array that
searches through each array for the highest value, and puts its key
into another array, to create a new array of key/key values

Edit
I’m looking through all 0’s, then all 1’s, then all 2’s to find the highest value there. I want to always start with whatever the all time highest number is though, and move on to the smallest as the keys become unavailabl

Input would be this

Array
(
    Array
    (
        [0] => 16 
        [1] => 27 
        [2] => 36 // highest, 2 is now unavailable
    )
    Array
    (
        [0] => 27
        [1] => 13.5  // highest, 1 is now unavailable
        [2] => 9 
    )
    Array
    (
        [0] => 81 // highest, 0 is now unavailable
        [1] => 18
        [2] => 27 
    )
)

Output would be this

Array
(
    [0] => [2]
    [1] => [1]
    [2] => [0]
)
  • 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-25T03:44:07+00:00Added an answer on May 25, 2026 at 3:44 am

    Something along these lines should do it, if I’m getting you right:

    $result = array();
    
    foreach ($array as $numbers) {
        $highestKey = null;
        $highestNum = null;
    
        foreach ($numbers as $key => $value) {
            if ($value > $highestNum && !in_array($key, $result)) {
                list($highestKey, $highestNum) = array($key, $value);
            }
        }
    
        $result[] = $highestKey;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone have any comparative thoughts on these three technologies? Each addresses a different VM,
I have three tables in my DB (actually a few more than that) these
I have an array of data that looks like this: 2008, Honda, Accord, Used,
I have a Moose class that i would like to store using Apache::Session::File. However,
I have a number of items in an array, each one associated to a
Let us suppose i have these three methods defined: int F1(int, int); int F1(float,
I have an iphone app where I call these three functions in appDidFinishLaunching: glMatrixMode(GL_PROJECTION);
I have a view from which I am selecting three columns. Of these three
I have 3 function in my class B. These three function have to access
I want to show three XMLs on a single html page. These XMLs have

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.