Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have the following:

( [0] => 3 [1] => 2 [2] => 12 [3] => 6 [4] => 8 [5] => 7 [6] => 9 [7] => 10 [8] => 5 [9] => 4 )

I want to use the value of each of those as the key in:

( [0] => 7 [1] => 2 [2] => 10 [3] => 3 [4] => 5 [5] => 6 [6] => 11 [7] => 9 [8] => 4 [9] => 8 )

I've tried this:

foreach ($iOrder as $i)
{
    $pOrder[$i] = $pOrder[$p];

    $p++;
}

I get this:

( [12] => 2 [10] => 6 [5] => 5 [4] => 7 )

Any thoughts?

share|improve this question
    
PS. The first array listed is $idOrder and the second is $pOrder. –  dleturno Jul 26 '11 at 19:13
    
    
And what do you want to have as result? –  Nin Jul 26 '11 at 19:21
    
I expect the $pOrder array to be: [3] => 7 [2] => 2 [12] => 10 and so on and so forth. The length of $pOrder should be 10, not 4. –  dleturno Jul 26 '11 at 19:31

1 Answer 1

Do you mean

$result = array_combine($keys, $values);

?

array_combine()

share|improve this answer
    
Tried that. Seems to be erroring using the above arrays as key/value. –  dleturno Jul 26 '11 at 19:30
    
Don't see any error. Additional, I don't know, what it should mean, when there only seems to be something erroneous. –  KingCrunch Jul 26 '11 at 19:33
    
Fat fingered it. Sorry. Thanks for the help. –  dleturno Jul 26 '11 at 19:35
    
@dieturno: Remeber to accept the answer, if it helps you solving your problem. –  KingCrunch Jul 26 '11 at 22:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.