C
C
Cesare Borgia2014-08-18 17:58:29
PHP
Cesare Borgia, 2014-08-18 17:58:29

How to find the maximum value in one array related to another by id?

Good evening, dear connoisseurs!
Please tell me how to solve this problem.
I have two arrays. One array is the user id values ​​=> points count and the other array is the user id => user category.

Array
(
    // id => score
    [5] => 14
    [1] => 10
    [3] => 6
    [8] => 3
    [7] => 1
    [4] => 0
)

Array
(
    // id => category
    [5] => 21
    [1] => 4
    [3] => 6
    [8] => 23
    [7] => 23
    [4] => 5
)

Ideally, I would like to know how to get an array in which there will be a category => id of the user with the maximum number of points in this category.
Tell me, please, how can I do it better?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-08-18
@servdo

Tasks at school are set so that you do them yourself.
It doesn't even have a nested loop. You will succeed!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question