Hi guys and gals,

I am having great difficulties with getting hold of the last 10 elements (maintaining key associations) of a multidimensional associative array.

$myArray["key"] = array(12,81);

Meaning the array format is;

array{
 ["key"] =>
array{
 [0]=>"12"
 [1]=>"81"
 }
}

I need to get hold of the last 10 elements of the array, with the key=>val maintained. This means I cannot do this;

array_slice ($myArray, count($myArray)-10,10); 

As the indices are lost??

I also tried uising arsort, and then using a conditional for each loop, with a manual counter,
however it sorted on the incorrect array element. Im tearing my hair out, any suggestions?

    just an idea that I think might work:

    What if you use array_reverse() to reverse the order of the array, then run a for loop 10 times to get the last ten keys?

    I don't know, this would be something you'd just want to play around with till you got it. That's usually how I get things to work. 😃

    Cgraz

      Write a Reply...